Results 1 to 12 of 12

Thread: qRegisterMetaType vs. uint64

  1. #1
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default qRegisterMetaType vs. uint64

    Hi!

    I just noticed that the Qt meta system wont accept unsinged 64bit integers in its signal/slot calling system.
    I am trying to connect a slot with a signal, both of type

    Qt Code:
    1. void testtest(uint64 t);
    To copy to clipboard, switch view to plain text mode 

    uint64 is a typedef for 64 bit integers in VS:

    Qt Code:
    1. typedef unsigned __int64 uint64;
    To copy to clipboard, switch view to plain text mode 

    the connect() call returns true, but when the signal is emitted, Qt outputs this:

    QObject::connect: Cannot queue arguments of type 'uint64'
    (Make sure 'uint64' is registered using qRegisterMetaType().)

    Hm. I would have assumed uint64 to be covered, but oh well, i added this right after the typedef:

    Qt Code:
    1. Q_DECLARE_METATYPE(uint64)
    To copy to clipboard, switch view to plain text mode 

    Everything compiles fine, the connect() call succeeds - but when i emmit the signal, Qt errors out again with above message.


    Help?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qRegisterMetaType vs. uint64

    Qt performs char by char comparison of type names thus you can't use typedefs or defines, the names have to match literally (both in the connect statement and in signal/slot prototypes).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qRegisterMetaType vs. uint64

    To use the type T in QVariant, using Q_DECLARE_METATYPE() is sufficient. To use the type T in queued signal and slot connections, qRegisterMetaType<T>() must be called before the first connection is established.
    http://doc.qt.digia.com/qt/qmetatype...sterMetaType-2
    Last edited by amleto; 22nd November 2012 at 17:19.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  4. #4
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qRegisterMetaType vs. uint64

    Ok, thanks.

    Based on above link, i a m now calling

    int id = qRegisterMetaType<uint64>();
    right before my connect() call. Doesnt change anything, though.
    The returned value in "id" is 5.

    "quint64" is registered properly already and works. However, i`d really like to get this to work with custom types...

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qRegisterMetaType vs. uint64

    Show us your exact connect statement and signal and slot declarations.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qRegisterMetaType vs. uint64

    Qt Code:
    1. signals:
    2. void ItChange(uint64 n);
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. public slots:
    2. void OnItChange(uint64 n);
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. int id = qRegisterMetaType<uint64>(); //returns 5
    2. connect(pl, SIGNAL(ItChange(uint64)), zu, SLOT(OnItChange(uint64))); //returns true
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qRegisterMetaType vs. uint64

    Do pl and zu live in different threads?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qRegisterMetaType vs. uint64

    potentially, yes. i hadnt considered that to be much of a problem, because built-in data types like quint64 work fine.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qRegisterMetaType vs. uint64

    It's not about "potentially". If those objects live in the same thread, in normal conditions you shouldn't be seeing the message about uint64 being unregistered. Therefore it is important to establish whether they are in different threads or not. It would be best if you prepared a minimal compilable example reproducing the problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qRegisterMetaType vs. uint64

    not on my developing machine this weekend, but yes they are in two different threads.
    i`ll provide an example later on monday.

  11. #11
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qRegisterMetaType vs. uint64

    You could try to reduce the example by putting a value of that type into a QVariant.
    Ultimately this is what happens to signal arguments in a cross-thread connection.

    something like

    Qt Code:
    1. uint64 i = 1234;
    2. QVariant v = QVariant::fromValue<uint64>( i );
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qRegisterMetaType vs. uint64

    He could just use quint64
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 3
    Last Post: 23rd April 2013, 14:38
  2. Replies: 4
    Last Post: 9th September 2009, 09:02
  3. qRegisterMetaType: getting garbage through signal/slot
    By zlacelle in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2009, 09:05
  4. qRegisterMetaType - problems with connect()
    By Macok in forum Qt Programming
    Replies: 1
    Last Post: 5th March 2009, 22:55
  5. qRegisterMetaType and own class
    By ^NyAw^ in forum Qt Programming
    Replies: 3
    Last Post: 9th January 2008, 12:20

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.