[Qt-interest] Passing QStringList with signals

Andre Somers andre at familiesomers.nl
Wed Aug 18 22:38:55 CEST 2010


  Op 18-8-2010 22:16, siteshwar at gmail.com schreef:
> Hello,
>
> I was trying to pass some data using QStringList as argument to a signal in
> my Qt application; but since QStringList doesn't derive from QObject;
> passing it is not allowed. What's the advised way to do so ?
That has nothing to do with QStringList not deriving from QObject.
You can pass any type through signals and slots, they just need to be 
registered with the meta type system. QStringList already is, so you 
should have no problem to pass it. Other types can be passed through a 
signal using the Q_DECLARE_METATYPE macro; see QMetaType documentation 
for details.
There is one catch: if you need your data to be passed through queued 
signals, you also need to use qRegisterMetaType. That is normally only 
needed if you use threading though, or if you want to use the type in 
conjunction with the Qt property system.

André




More information about the Qt-interest-old mailing list