Results 1 to 6 of 6

Thread: QObject::connect: Cannot queue arguments of type 'MyStruct'

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2009
    Posts
    90
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QObject::connect: Cannot queue arguments of type 'MyStruct'

    hi,
    I always after application running, receive debug text of:
    QObject::connect: Cannot queue arguments of type 'MyStruct'
    (Make sure 'MyStruct' is registered using qRegisterMetaType().)

    I have defined MyStruct in an accessible header file:

    myheader.h
    ////////////////////
    Qt Code:
    1. #ifndef MYHEADER_H
    2. #define MYHEADER_H
    3.  
    4. #include <QObject>
    5. #include <QMetaType>
    6.  
    7. struct MyStruct
    8. {
    9. int ...
    10. QString ...
    11. double ...
    12.  
    13. MyStruct(...) :
    14. ...
    15. {}
    16.  
    17. MyStruct operator=(const MyStruct& tother)
    18. {
    19. ...
    20. return *this;
    21. }
    22.  
    23. bool operator!=(const MyStruct& tother)
    24. {
    25. ...
    26. }
    27.  
    28. };
    29. Q_DECLARE_METATYPE(MyStruct)
    30.  
    31.  
    32. class MyHeader: public QObject
    33. {
    34. Q_OBJECT
    35.  
    36. ...
    37.  
    38. }
    39.  
    40. #endif // MYHEADER_H
    To copy to clipboard, switch view to plain text mode 
    ///////////////////

    and I have used it in a thread:


    mythread.h
    ////////////
    Qt Code:
    1. ...
    2. #include <QThread>
    3. #include "myheader.h"
    4. #include <QMetaType>
    5.  
    6.  
    7. Q_DECLARE_METATYPE(QList<int>)
    8. Q_DECLARE_METATYPE(QList<MyStruct>)
    9.  
    10. class MyThread: public QThread
    11. {
    12. Q_OBJECT
    13. ...
    14. }
    15. ...
    To copy to clipboard, switch view to plain text mode 
    //////////




    mythread.cpp
    //////////////////
    Qt Code:
    1. #include "mythread.h"
    2.  
    3.  
    4. MyThread::MyThread(QObject *parent):
    5. QThread(parent)
    6. {
    7. }
    8.  
    9. MyThread::~MyThread()
    10. {
    11. }
    12.  
    13. void MyThread::run()
    14. {
    15. qRegisterMetaType<QList<int> >();
    16. qRegisterMetaType< QList<MyStruct> >();
    17.  
    18. ThreadReceiverObject * my_reciever = new ThreadReceiverObject();
    19.  
    20. QObject::connect(otherthread,SIGNAL(sigReqSchedule(QList<MyStruct>, QList<int>, int)),
    21. my_reciever,SLOT(onReqSchedule(QList<MyStruct>, QList<int>, int)));
    22.  
    23. ...
    24.  
    25. }
    To copy to clipboard, switch view to plain text mode 
    /////////////////

    where is the problem?
    Last edited by navid; 28th March 2010 at 16:03.

Similar Threads

  1. Can we connect QTimer::SingleShot with a slot taking arguments?
    By maverick_pol in forum Qt Programming
    Replies: 4
    Last Post: 17th September 2008, 18:02
  2. QObject::connect: Cannot queue arguments of type 'QString&'
    By Dumbledore in forum Qt Programming
    Replies: 3
    Last Post: 9th November 2007, 22:15
  3. Replies: 6
    Last Post: 21st September 2007, 13:51
  4. Replies: 4
    Last Post: 10th November 2006, 15:38
  5. Cannot queue arguments of type 'QStringList'
    By vfernandez in forum Qt Programming
    Replies: 2
    Last Post: 19th April 2006, 20:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.