QObject::connect: Cannot queue arguments of type

问题:

Hi!

I have a small problem concerning two threads and signals/slots connected between them.

My connect looks like this.

  1. ...
  2. qRegisterMetaType < QVector < QVector < int >  >  > ( "MyArray" ) ;
  3. ...
  4. connect (sender , SIGNAL (dataChanged ( QVector < QVector < int >  > ) ) ,receiver , SLOT (hasDataChanged ( QVector < QVector < int >  > ) ) ) ;

If the signal is being emitted, I get this error:

  1. QObject :: connect : Cannot queue arguments of type 'QVector<QVector<int> >'
  2. (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:

  1. 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

  1. signals :
  2.     void dataChanged ( const  QVector < QVector < int >  >  &data ) ;

Receiver

  1. public  slots :
  2.      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!

解决方法:

  1. typedef  QVector < QVector < int >  > MyArray ;
  2. // ...
  3. qRegisterMetaType <MyArray > ( "MyArray" ) ;
  4. // ...
  5. connect (
  6.      this , SIGNAL (blurbDone2 (MyArray ) ) ,
  7.      this , SLOT (slotBlurb2 (MyArray ) ) ,
  8.      Qt :: QueuedConnection ) ;
  9.  
  10. // with this signatures:
  11. signals :
  12.      void blurbDone2 ( const MyArray  &bb ) ;
  13.  
  14. protected  slots :
  15.      void slotBlurb2 ( const MyArray  &bb ) ;


转自:http://qt-project.org/forums/viewthread/2884

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值