Results 1 to 2 of 2

Thread: qt signal defined in macro

  1. #1
    Join Date
    Nov 2009
    US, Midwest
    Thanked 4 Times in 4 Posts
    Qt products
    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();
    10. class options : public QObject
    11. {
    12. Q_OBJECT
    13. public:
    14. options();
    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.

    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 03:12. Reason: found the answer

  2. #2
    Join Date
    Jan 2006
    Warsaw, Poland
    Thanked 5,009 Times in 4,788 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Unix/X11 Windows Android Maemo/MeeGo
    Blog Entries
    Wiki edits

    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, 05:44
  2. Replies: 6
    Last Post: 3rd December 2012, 08: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, 14:07
  4. Signal and "already defined" error
    By QPlace in forum Qt Programming
    Replies: 3
    Last Post: 4th June 2009, 03:06
  5. User Defined Signal?
    By rajeshs in forum Newbie
    Replies: 2
    Last Post: 18th December 2007, 12:42

Tags for this Thread


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.