Results 1 to 4 of 4

Thread: Proper place to declare meta types (qRegisterMetaType())

  1. #1
    Join Date
    Jan 2013
    Posts
    16
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Android

    Default Proper place to declare meta types (qRegisterMetaType())

    I have a number of types I want to declare with qRegisterMetaType. As I understand it, this must be done after QApplication::exec(). Since I don't want to be doing this all over the place, where is a good place to make all my qRegisterMetaType() calls?

  2. #2
    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: Proper place to declare meta types (qRegisterMetaType())

    Depending on what you do you might not need explicit qRegisterMetaType() calls at all, e.g. when using QVariant::fromValue() it will take care of that.

    In any case you don't need to delay that to the execution of the main event loop, Qt's meta type system can be used without any application object.

    Cheers,
    _

  3. #3
    Join Date
    Jan 2013
    Posts
    16
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Android

    Default Re: Proper place to declare meta types (qRegisterMetaType())

    I'm passing these types around in signals and slots.

  4. #4
    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: Proper place to declare meta types (qRegisterMetaType())

    I assume Cross-Thread or Qt::QueuedConnection connections?
    (direct connections don't need registered meta types).

    In that case just register at the begin of your main function, or in the constructor of your main object/window.

    Cheers,
    _

Similar Threads

  1. qRegisterMetaType vs. uint64
    By tuli in forum Qt Programming
    Replies: 11
    Last Post: 24th November 2012, 13:44
  2. Replies: 4
    Last Post: 10th December 2009, 16:37
  3. qRegisterMetaType - problems with connect()
    By Macok in forum Qt Programming
    Replies: 1
    Last Post: 5th March 2009, 22:55
  4. qRegisterMetaType and own class
    By ^NyAw^ in forum Qt Programming
    Replies: 3
    Last Post: 9th January 2008, 12:20
  5. Meta Types and QVariant
    By kroenecker in forum Qt Programming
    Replies: 4
    Last Post: 26th February 2007, 07: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.