PDA

View Full Version : Signal/slot using QVariant



ottawaDan
1st December 2010, 18:21
Good afternoon,

I am using Qt4.6, code written in C++. I am trying to create a generic signal/slot using QVariant as one of the passed arguments - see the prototypes below. I looked at the Qt source code and saw that sub-attac/torpedo.cpp contains an example of what I am trying to achieve and used this as a starting point.

signal declaration:

void configArgument( int, const QVariant &);
signal emitted:


QVariant qVariant;
qVariant.setValue( exposureTime);
emit configArgument( (int)CAMERA_EXPTIME, qVariant);

where exposureTime is declared as an int, CAMERA_EXPTIME is an enum

slot declaration:

void configArgument( int, const QVariant &);
connect statement:

connect( m_scriptEngine,SIGNAL( configArgument( int, QVariant)), this, SLOT( configArgument( int, QVariant)),Qt::QueuedConnection);
The signal is simply not processed by the slot.

I also tried using QVariant only (not as a const reference) in the declaration without changes.
There are no compilation warnings nor runtime message displayed related to thes signal/slot.

I traced thru the code and the signal appears to be emitted properly. Am I missing something?

If I replace the QVariant argument by an int (as below) in the different declarations, then the code is working properly.

void configArgument( int, int);

Thanks in advance
Daniel