[Kdenlive-devel] Problems with signals and slots

Simon Eugster simon.eu at gmail.com
Wed Dec 8 18:07:31 UTC 2010


With some delay now what I have found out (with the help of #qt).
The signal/slot connection uses the normalized signature[1] of a
function, i.e. dropping nearly all keywords. So in fact I could ignore
all & and const and so on.
But, there is a bug in earlier Qt versions (mine included, 2.6.3
afair) (or they just changed their mind and also the
normalizedSignature function). The class below should return true
always, but does not for the second case here in my Qt version (it
does for 4.7.1+ at least).

I think I have introduced the diff when committing, this was not the
initial problem ;) Nevertheless thanks for fixing, allowed me to
continue programming.

Simon

[1] http://doc.qt.nokia.com/4.7/qmetaobject.html#normalizedSignature

#include <QtCore>
class Test : public QObject
{
    Q_OBJECT

signals:
    void signal(const QVector<int16_t>&,int,int,int);
};

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    Test t;
    qDebug() << QObject::connect(&t, SIGNAL(signal(const
QVector<int16_t>&,int,int,int)), &a, SLOT(quit()));
    qDebug() << QObject::connect(&t, SIGNAL(signal(const
QVector<int16_t>,int,int,int)), &a, SLOT(quit()));
    qDebug() << QObject::connect(&t,
SIGNAL(signal(QVector<int16_t>,int,int,int)), &a, SLOT(quit()));

    qDebug() << QMetaObject::normalizedSignature("signal(const
QVector<int16_t>&,int,int,int)");
    qDebug() << QMetaObject::normalizedSignature("signal(const
QVector<int16_t>,int,int,int)");
    qDebug() <<
QMetaObject::normalizedSignature("signal(QVector<int16_t>,int,int,int)");
    return a.exec();
}
#include "main.moc"

2010/11/24 Marco Gittler <marco at gitma.de>:
> HI
>
> the & is required to copy only the const reference for the object.
> else you would make a const copy (maybe the compiler will correct this to const &, since it is for the usage the same).
> but this was not the problem with the signals, it was the diff in the mainwindow.cpp at top.
>
> regards marco
>
> Am 24.11.2010 um 12:37 schrieb Simon Eugster:
>
>> Hey Marco,
>>
>> Thanks! Working here.
>> Why is the & required? Did you just use trial&error, or is there a
>> rule that makes sense?
>>
>> Simon
>>
>> 2010/11/24 Marco Gittler <marco at gitma.de>:
>>> Hi
>>>
>>> I used the new (your) signals with QVector and rewrote the audiosignal.cpp (commited to svn)
>>>
>>> regards marco
>>>
>>> Am 24.11.2010 um 11:10 schrieb Simon Eugster:
>>>
>>>> Well, the «old» signal (using volume) _does_ work, but I cannot explain why.
>>>> When I try to do the same with my new signal, it does not work.
>>>>
>>>> Simon
>>>>
>>>> 2010/11/24 Marco Gittler <marco at gitma.de>:
>>>>> Hi
>>>>>
>>>>> I'll change this, to get it working (first on the "old" audiosignal)
>>>>> You can use this then for your audiospectrum.
>>>>>
>>>>>
>>>>> regards marco
>>>>>
>>>>> Am 24.11.2010 um 09:42 schrieb Simon Eugster:
>>>>>
>>>>>> Good Morning,
>>>>>>
>>>>>> I'm battling around with Qt's signals and slots. In r5116,
>>>>>> mainwindow.cpp:296 I want to connect my audiospectrum object to
>>>>>> Render::audioSamplesSignal. But whatever I do, my method never
>>>>>> receives the signal, although connecting works according to the return
>>>>>> value, Q_ASSERT etc.
>>>>>>
>>>>>> On line 298 I tried to find a reason for it and used the audio volume
>>>>>> signal. It is defined as:
>>>>>>  void showAudioSignal(const QByteArray);
>>>>>> According to the Qt documentation and some people in #qt, Qt uses
>>>>>> normalizedSignature[1] for signal/slot connections. Meaning that I
>>>>>> should be able to just use
>>>>>>  SIGNAL(showAudioSignal(QByteArray))
>>>>>> to connect the signal. But then connecting fails, telling me that
>>>>>> there is no such signal.
>>>>>>
>>>>>> I do not get an error though when using
>>>>>>  SIGNAL(showAudioSignal(const QByteArray)
>>>>>> i.e. the connection is set up correctly. Nevertheless the connected
>>>>>> slot is never called. Only if I use
>>>>>>  SIGNAL(showAudioSignal(const QByteArray&)
>>>>>> connecting works AND the slot gets called. Although the & is not in
>>>>>> showAudioSignal's signature.
>>>>>>
>>>>>> So I tried to use the & for my signal (audioSamplesSignal) as well:
>>>>>>  audioSamplesSignal(const QVector<int16_t>&,int,int,int)
>>>>>> with
>>>>>>  void audioSamplesSignal(const QVector<int16_t>,int,int,int)
>>>>>> but this fails with «no such signal». Why should I have to add a & for
>>>>>> a QByteArray, but I'm forbidden to do so for the QVector?
>>>>>>
>>>>>> I then tried to change everything (including the signal's signature)
>>>>>> to const type& (whether making sense or not – what I noticed above
>>>>>> does not make sense to me anyway). But still, no signal received.
>>>>>>
>>>>>> Can anyone help me? Why is qt behaving that way? What is the problem?
>>>>>>
>>>>>> thanks
>>>>>> Simon
>>>>>>
>>>>>> [1] http://doc.qt.nokia.com/4.7/qmetaobject.html#normalizedSignature
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
>>>>>> Tap into the largest installed PC base & get more eyes on your game by
>>>>>> optimizing for Intel(R) Graphics Technology. Get started today with the
>>>>>> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
>>>>>> http://p.sf.net/sfu/intelisp-dev2dev
>>>>>> _______________________________________________
>>>>>> Kdenlive-devel mailing list
>>>>>> Kdenlive-devel at lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/kdenlive-devel
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
>>>>> Tap into the largest installed PC base & get more eyes on your game by
>>>>> optimizing for Intel(R) Graphics Technology. Get started today with the
>>>>> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
>>>>> http://p.sf.net/sfu/intelisp-dev2dev
>>>>> _______________________________________________
>>>>> Kdenlive-devel mailing list
>>>>> Kdenlive-devel at lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/kdenlive-devel
>>>>>
>>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
>>>> Tap into the largest installed PC base & get more eyes on your game by
>>>> optimizing for Intel(R) Graphics Technology. Get started today with the
>>>> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
>>>> http://p.sf.net/sfu/intelisp-dev2dev
>>>> _______________________________________________
>>>> Kdenlive-devel mailing list
>>>> Kdenlive-devel at lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/kdenlive-devel
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
>>> Tap into the largest installed PC base & get more eyes on your game by
>>> optimizing for Intel(R) Graphics Technology. Get started today with the
>>> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
>>> http://p.sf.net/sfu/intelisp-dev2dev
>>> _______________________________________________
>>> Kdenlive-devel mailing list
>>> Kdenlive-devel at lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/kdenlive-devel
>>>
>>>
>>
>> ------------------------------------------------------------------------------
>> Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
>> Tap into the largest installed PC base & get more eyes on your game by
>> optimizing for Intel(R) Graphics Technology. Get started today with the
>> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
>> http://p.sf.net/sfu/intelisp-dev2dev
>> _______________________________________________
>> Kdenlive-devel mailing list
>> Kdenlive-devel at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/kdenlive-devel
>
>
> ------------------------------------------------------------------------------
> Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
> Tap into the largest installed PC base & get more eyes on your game by
> optimizing for Intel(R) Graphics Technology. Get started today with the
> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
> http://p.sf.net/sfu/intelisp-dev2dev
> _______________________________________________
> Kdenlive-devel mailing list
> Kdenlive-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/kdenlive-devel
>
>




More information about the Kdenlive mailing list