Results 1 to 3 of 3

Thread: Q_PROPERTY WRITE function, also a slot?

  1. #1
    Join Date
    Aug 2009
    Posts
    50
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Q_PROPERTY WRITE function, also a slot?

    Hello,

    A fairly common format for a Qt class, which I make use of often, is:

    Qt Code:
    1. class Garden : public QWidget
    2. {
    3. Q_OBJECT
    4. Q_PROPERTY(double wheelBarrow READ wheelBarrow WRITE setWheelBarrow);
    5. .
    6. .
    7.  
    8. public:
    9. // Constructor:
    10. .
    11. .
    12. void setWheelBarrow(const double &newWheelBarrow);
    13. etc.
    14.  
    15. public slots:
    16. void updateWheelBarrow(const double &newWheelBarrow);
    17. .
    18. .
    19. .
    20. };
    To copy to clipboard, switch view to plain text mode 

    Quite often, setWheelBarrow and updateWheelBarrow do different things (for example, updateWheelBarrow may need to update some other parameters which depend on wheelBarrow, which setWheelBarrow assumes will be set directly by the parent) , but sometimes they do exactly the same thing. In the cases where they are exactly the same, can the same function be used? Or is it always necessary for Q_PROPERTY functions and slots to be separate entities?

    Thanks,
    Stephen.

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

    Default Re: Q_PROPERTY WRITE function, also a slot?

    Q_PROPERTY function for setting the value of a property can (and in most cases should) be a slot.
    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
    Aug 2009
    Posts
    50
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Q_PROPERTY WRITE function, also a slot?

    Jolly good; thank you very much.

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. Regading Driver to connect Postgresql Database
    By dummystories in forum Installation and Deployment
    Replies: 38
    Last Post: 12th March 2009, 07:19
  3. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  4. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52

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.