Results 1 to 3 of 3

Thread: Problem using qRegisterMetaType

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Problem using qRegisterMetaType

    Hello!

    I want to do some non-basic signal-slot connections between a QThread and the MainWindow class and reading Qt's Assistant documentation I found that I need to use qRegisterMetaType() to register the data-container types in case I'm using non-standart types, and this is what I did:

    Qt Code:
    1. struct analysis_results
    2. {
    3. POSITION share_id;
    4. TYPE analysis_type;
    5.  
    6. PROBABILITY probability;
    7. QString text;
    8. };
    9.  
    10.  
    11. qDebug() << QMetaType::isRegistered(qRegisterMetaType<THREAD>("THREAD_type"));
    12. qDebug() << QMetaType::isRegistered(qRegisterMetaType<analysis_study>("analysis_study"));
    13. qDebug() << QMetaType::isRegistered(qRegisterMetaType<analysis_results>("analysis_results"));
    14. qDebug() << QMetaType::isRegistered(qRegisterMetaType< QList<analysis_results> >("analysis_results_list"));
    15.  
    16.  
    17. connect(threadEstudo,SIGNAL(sinalTerminoCalculos(analysis_study,uchar,bool)),this,SLOT(slotAnaliseEstudosTerminoCalculos(analysis_study,uchar,bool)));
    18. connect(threadEstudo,SIGNAL(sinalMemoLog(QString)),this,SLOT(slotMemoLog(QString)));
    19. connect(threadEstudo,SIGNAL(sinalPrimeiroEstudo()),this,SLOT(slotShowReviewWindowFirstTime()));
    20. connect(threadEstudo,SIGNAL(sinalResultados(QList<analysis_results>)),this,SLOT(slotAvaliaResultadosEstudo(QList<analysis_results>)));
    To copy to clipboard, switch view to plain text mode 

    You may notice that I put the qDebug() so I can check if all metatypes were correctly registered, and the result was "true" for all of them.

    The problem is that when I actually use the signal (sinalResultados(QList<analysis_results>)), the connection fails and I receive the debug message:

    QObject::connect: Cannot queue arguments of type 'QList<analysis_results>'
    (Make sure 'QList<analysis_results>' is registered using qRegisterMetaType().)

    What could be the problem with this specific case? Why it returns true when I verify for the correct registration but actually it gives me errors?


    Thanks,

    Momergil

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Problem using qRegisterMetaType

    Hi, use
    Qt Code:
    1. typedef QList<analysis_results> analysis_results_list;
    2. qRegisterMetaType<analysis_results_list>( "analysis_results_list" );
    To copy to clipboard, switch view to plain text mode 
    Then it should work.

  3. The following user says thank you to Lykurg for this useful post:

    Momergil (20th February 2013)

  4. #3
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Problem using qRegisterMetaType

    Thanks!

    Tip for Qt developers: put this note in Qt Assistant; I would have never gessed that.

    Momergil

Similar Threads

  1. qRegisterMetaType vs. uint64
    By tuli in forum Qt Programming
    Replies: 11
    Last Post: 24th November 2012, 14:44
  2. Replies: 4
    Last Post: 9th September 2009, 10:02
  3. qRegisterMetaType: getting garbage through signal/slot
    By zlacelle in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2009, 10:05
  4. qRegisterMetaType - problems with connect()
    By Macok in forum Qt Programming
    Replies: 1
    Last Post: 5th March 2009, 23:55
  5. qRegisterMetaType and own class
    By ^NyAw^ in forum Qt Programming
    Replies: 3
    Last Post: 9th January 2008, 13:20

Tags for this Thread

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.