Results 1 to 5 of 5

Thread: enlighten me on the use of Q_PROPERTY!!

  1. #1
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Wink enlighten me on the use of Q_PROPERTY!!

    Hi,

    Why should one use Q_PROPERTY? as in what advantage does it have over declaring the corresponding attributes and associated READ and WRITE functions as private/public??

    Thanks

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: enlighten me on the use of Q_PROPERTY!!

    Properties can be written and read through QObject interface.
    You can access the properties without knowing anything about the class in use.
    Qt's Property System

    It's not the fastest possible way to access data members of a class, the value of properties comes from genericity.
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: enlighten me on the use of Q_PROPERTY!!

    Quote Originally Posted by nupul
    Why should one use Q_PROPERTY?
    It's used for example by the Qt Designer to change widgets' settings.

    Quote Originally Posted by nupul
    what advantage does it have over declaring the corresponding attributes and associated READ and WRITE functions as private/public??
    Actually you will still need to write such methods. Q_PROPERTY just informs Qt about them.

  4. #4
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: enlighten me on the use of Q_PROPERTY!!

    Quote Originally Posted by jacek
    Actually you will still need to write such methods. Q_PROPERTY just informs Qt about them.
    how does this help? i mean how is it different from declaring a private attribute and corresponding methods..Any advantage?

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: enlighten me on the use of Q_PROPERTY!!

    Quote Originally Posted by nupul
    Any advantage?
    Look at the Qt Designer --- it doesn't know anything about custom widgets, yet if you create a custom widget plugin, you will be able to change that widgets' properties. How would you implement this without Q_PROPERTY?

  6. The following user says thank you to jacek for this useful post:

    nupul (3rd April 2006)

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.