写了一个这样的信号

 

void caculateReady( QList<QString> adds, QList<double> hotV, QList<double> coolV);

 

编译时正常,运行时了现错误

Object::connection: Cannot queue arguments of type 'QList<QString>'

(Make sure 'QList<QString>' is registered using qRegisterMetaType().))

原因:自定义的数据类型作为信号槽参数传递的时候,需要使用 qRegisterMetaType() 函数对该参数进行注册

代码修改如下:

 

  1.  
    //添加文件引用
  2.  
    #include <QMetaType>

 

  1.  
    //注册参数类型
  2.  
    qRegisterMetaType<QList<QString> > ("QList<QString>");

 

这样,这个QList<QString>就可以作为信号参数来传递了

F1出现的help文档中的定义为:

 

  1.  
    int qRegisterMetaType ( const char * typeName )
  2.  
    //实例
  3.  
    qRegisterMetaType<MyClass>("MyClass");


qRegisterMetaType的返回值为自定义类型的ID

 

 

参考:http://blog.csdn.net/kusey/article/details/7995815

相关文章:

  • 2022-02-20
  • 2022-12-23
  • 2022-12-23
  • 2021-07-26
  • 2022-12-23
  • 2022-12-23
  • 2021-11-14
猜你喜欢
  • 2022-12-23
  • 2021-05-05
  • 2022-12-23
  • 2022-12-23
  • 2022-03-07
  • 2021-12-20
  • 2021-08-19
相关资源
相似解决方案