Results 1 to 2 of 2

Thread: qt signal defined in macro

  1. #1
    Join Date
    Nov 2009
    Location
    US, Midwest
    Posts
    215
    Thanks
    62
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qt signal defined in macro

    I defined the signal in the macro:
    Qt Code:
    1. #define PROP_SINGLEVAL(prpname) \
    2. private: \
    3. int _##prpname; \
    4. public: \
    5. int& prpname () {return _##prpname;}; \
    6. const int& ##prpname() const {return _##prpname;}; \
    7. signals: \
    8. void on##prpname##Change();
    9.  
    10. class options : public QObject
    11. {
    12. Q_OBJECT
    13. public:
    14. options();
    15.  
    16. PROP_SINGLEVAL(val)
    17. };
    To copy to clipboard, switch view to plain text mode 

    It compiles but, when trying to connect the signal to the slot of another object instance, the message is that the signal on options:nvalChange() does not exist. I think I understand the reason for it (moc preprocessing does not expand the macro). Perhaps there is a way to make it work? I have many variables and for each one I want to provide the signal when it is changing.
    Thanks.


    Added after 7 minutes:


    Can't find the way to delete the post, hence the answer: Q_SIGNAL
    Last edited by TorAn; 12th August 2018 at 02:12. Reason: found the answer

  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: qt signal defined in macro

    Why not use Q_PROPERTY with MEMBER and NOTIFY and let Qt do all the magic for you?
    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. Replies: 2
    Last Post: 8th November 2016, 04:44
  2. Replies: 6
    Last Post: 3rd December 2012, 07:26
  3. DEBUG macro not defined in debug build using vc++
    By piotr.dobrogost in forum Qt Programming
    Replies: 0
    Last Post: 21st July 2009, 13:07
  4. Signal and "already defined" error
    By QPlace in forum Qt Programming
    Replies: 3
    Last Post: 4th June 2009, 02:06
  5. User Defined Signal?
    By rajeshs in forum Newbie
    Replies: 2
    Last Post: 18th December 2007, 11:42

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.