Results 1 to 3 of 3

Thread: Qt Guru Required for MetaObject system problem.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Qt Guru Required for MetaObject system problem.

    Hello,

    i have several questions about the Qt MetaObject system, related to issues i have with an application i'm working on.

    1) Namespace Enums.
    i have a very wide namespace named "RE". To allow declaration of enums and types inside that namespace while still being covered by the Qt MetaObject processing system, i use such trick:
    Qt Code:
    1. #ifdef Q_MOC_RUN
    2. class RELibOpt RE {
    3. Q_GADGET
    4. Q_ENUMS (AnEnum, AnotherEnum)
    5. public:
    6. #else
    7. namespace RE {
    8. #endif
    9. // My whole fake class / namespace comes here,
    10. // including all my enums declarations... Is there another way to make an enum "global" but still part of the parsed meta-object system?...
    11. }
    12.  
    13. Q_DECLARE_METATYPE(RE::AnEnum);
    14. Q_DECLARE_METATYPE(RE::AnotherEnum);
    To copy to clipboard, switch view to plain text mode 
    Is that right to do that? What would be the other solution to have a namespace containing enums and registered typedefs? i would like to be able to have my enums part of my "RE" namespace exactly as the Qt enums are part of the "Qt" namespace... What is Qt in this case? A class? A namespace? How is it processed by MOC?

    2) Properties and Enums.
    Still in my "RE" namespace, i have classes. In those classes, i use the Q_PROPERTY macro. However, if in a class RE::A i use a Q_PROPERTY using RE::AnEnum as it's base type, i'm unable to enumerate it's content with QMetaEnum: the QMetaProperty exists but says it's not an enum type! What is the solution to do that?

    Thanks a lot,
    Pierre.

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

    Default Re: Qt Guru Required for MetaObject system problem.

    There is a special code path in moc for processing the "Qt" namespace (yes, it is a namespace). It is impossible to use that path with user code unless something changed since the last time I analyzed the code (which was a couple of minor versions back). As for the second case I can only tell you to remember Qt meta-type system is based on a character-by-character string comparison. Can you access the enums defined in RE manually by processing its meta object?
    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. QObject::MetaObject()
    By pkj in forum Qt Programming
    Replies: 3
    Last Post: 4th June 2011, 10:41
  2. guru, novice, Beginner, Greenhorn, ...
    By john_god in forum General Discussion
    Replies: 1
    Last Post: 11th February 2009, 06:53
  3. system tray problem
    By vvdounai in forum Qt Programming
    Replies: 5
    Last Post: 14th November 2007, 08:25
  4. Help wanted from opencvlibrary Guru WebCam image... to avi..
    By patrik08 in forum General Programming
    Replies: 2
    Last Post: 18th May 2007, 00:52
  5. Example code and metaObject question
    By bruccutler in forum Newbie
    Replies: 1
    Last Post: 12th January 2007, 18:34

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
  •  
Qt is a trademark of The Qt Company.