您的位置:首页 > 移动开发 > Objective-C

QObject::connect: Cannot queue arguments of type

2013-06-13 18:04 726 查看
问题:

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 usingqRegisterMetaType().)

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!

解决方法:

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);

转自:http://qt-project.org/forums/viewthread/2884
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐