Results 1 to 2 of 2

Thread: Q_PROPERTY with QObject?

  1. #1
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Q_PROPERTY with QObject?

    Hi,

    My class is not derived from QObject, how can I still use Q_PROPERTY macro? I did the following:

    Qt Code:
    1. class MyClass
    2. {
    3. Q_GADGET
    4. Q_PROPERTY( ...... )
    5.  
    6. };
    To copy to clipboard, switch view to plain text mode 

    The moc system recognizes Q_GADGET tag and generates staticMetaObject, as well as those property names registered with Q_PROPERTY, but I can't use the QMetaProperty::read method to read the property value, as it expects QObject. Is there a way to work around (without sub-class from QObject)?

    Thanks!

  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: Q_PROPERTY with QObject?

    No, I don't think so. Q_GADGET only implements meta-type part of QObject functionality so that you can register flags, enums, etc. It's not a real QObject.
    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. Pointer in Q_PROPERTY
    By pkorzeniewski in forum Qt Programming
    Replies: 3
    Last Post: 20th September 2012, 09:32
  2. Q_property
    By micky in forum Qt Programming
    Replies: 2
    Last Post: 23rd April 2012, 18:51
  3. Why and when to use Q_PROPERTY
    By Vanir in forum Qt Programming
    Replies: 4
    Last Post: 22nd November 2007, 09:25
  4. How to Use Q_PROPERTY
    By mitesh_modi in forum Qt Programming
    Replies: 7
    Last Post: 20th June 2006, 14:49
  5. enlighten me on the use of Q_PROPERTY!!
    By nupul in forum Newbie
    Replies: 4
    Last Post: 3rd April 2006, 10:02

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.