[SOLVED] Cross-Thread signal: Cannot queue arguments of type 'QVector<QVector<int> >
-
Hi!
I have a small problem concerning two threads and signals/slots connected between them.
My connect looks like this.
@
...
qRegisterMetaType<QVector<QVector<int> > >("MyArray");
...
connect(sender, SIGNAL(dataChanged(QVector<QVector<int> >)), receiver, SLOT(hasDataChanged(QVector<QVector<int> >)));
@If the signal is being emitted, I get this error:
@
QObject::connect: Cannot queue arguments of type 'QVector<QVector<int> >'
(Make sure 'QVector<QVector<int> >' is registered using qRegisterMetaType().)
@Also note that I have my sig/slots with a reference, but if I used a connect like this:
@
connect(sender, SIGNAL(dataChanged(QVector<QVector<int> >&)), receiver, SLOT(hasDataChanged(QVector<QVector<int> >&)));
@
I'm getting this:
Object::connect: No such signal dataChanged(QVector<QVector<int> >&)Sender
@
signals:
void dataChanged(const QVector<QVector<int> > &data);
@Receiver
@
public slots:
void hasDataChanged(const QVector<QVector<int> > &data);
@How can I achieve a connection, do I need to put Q_DECLARE_METATYPE somewhere?
Thanks for your help!
-
You should do a typedef:
@
typedef QVector<QVector<int> > MyArray;
// ...
qRegisterMetaType<MyArray>("MyArray");
// ...
connect(
this, SIGNAL(blurbDone2(MyArray)),
this, SLOT(slotBlurb2(MyArray)),
Qt::QueuedConnection);// with this signatures:
signals:
void blurbDone2(const MyArray &bb);protected slots:
void slotBlurb2(const MyArray &bb);
@This works for me.