Results 1 to 10 of 10

Thread: Q_PROPERTY compile problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2010
    Posts
    65
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Q_PROPERTY compile problem

    I'm starting to want to use the Q_PROPERTY system for a specific case. I have a class with a member which contains the information used in various modeless dialogs. However, since these dialogs are modeless, the information might be altered while they are running. So I thought of transforming this member into a Q_PROPERTY with a NOTIFY signal that I could then connect to the dialogs so they'd refresh themselves should this data be altered. However, the member is now no longer detected as a class data member and thus the class fails to compile (giving hundreds of "undeclared identifier" errors).

    The class declaration is the following:
    Qt Code:
    1. class Canvas : public QSFMLCanvas
    2. {
    3. Q_OBJECT
    4. Q_PROPERTY(std::vector<Fault> faults READ GetFaults WRITE SetFaults NOTIFY FaultsEdited)
    5. Q_PROPERTY(std::vector<Horizon> horizons READ GetHorizons NOTIFY HorizonsEdited)
    6. /*...*/
    7. //std::vector<Fault> faults;
    8. //std::vector<Horizon> horizons;
    9. /*...*/
    10. public:
    11. std::vector<Fault> GetFaults() const;
    12. void SetFaults(std::vector<Fault> v);
    13. std::vector<Horizon> GetHorizons() const;
    14. /*...*/
    15. signals:
    16. void FaultsEdited();
    17. void HorizonsEdited();
    18. };
    To copy to clipboard, switch view to plain text mode 

    As well, should I uncomment the original data members, it compiles just fine, but the NOTIFY signal is not emitted.
    Last edited by Wasabi; 7th January 2011 at 14:26.

Similar Threads

  1. how to implement QApplication.notify()
    By di_zou in forum Newbie
    Replies: 1
    Last Post: 15th February 2010, 18:12
  2. QApplication::notify()
    By jeffpogo in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2009, 22:46
  3. Qt web notify
    By bunjee in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 13:24
  4. Why and when to use Q_PROPERTY
    By Vanir in forum Qt Programming
    Replies: 4
    Last Post: 22nd November 2007, 09:25
  5. How to Use Q_PROPERTY
    By mitesh_modi in forum Qt Programming
    Replies: 7
    Last Post: 20th June 2006, 14:49

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.