Results 1 to 5 of 5

Thread: signal and slots

  1. #1
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default signal and slots

    Hello All,
    Qt Code:
    1. //.h
    2. class A
    3. {
    4. Q_OBJECT
    5. public:
    6. A(){}
    7. public slots:
    8. #ifdef SOMEMACRO
    9. void slotA();
    10. #endif
    11. };
    12. //.cpp
    13. #ifdef SOMEMACRO
    14. void A::slotA()
    15. {
    16. //..
    17. }
    18. #endif
    To copy to clipboard, switch view to plain text mode 
    If SOMEMACRO is "NOT DEFINED" will the above code compile?
    In my case it doesn't compile. Why?
    Is the moc_A.cpp file created before preprocessors being parsed by the compiler?

    Thanks

  2. #2
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Thanks
    9
    Thanked 29 Times in 29 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: signal and slots

    I think you just forgot the # of #ifdef.
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

  3. #3
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: signal and slots

    ifdefs don't work in headers that need to be moc'ed!

  4. #4
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: signal and slots

    Quote Originally Posted by marcel View Post
    ifdefs don't work in headers that need to be moc'ed!
    So mean to say, moc_A.cpp file is created before preprocessors being parsed by the compiler? M I right?

  5. #5
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: signal and slots

    Of course it is. And moc doesn't do well with macros.

Similar Threads

  1. doubts in signal and slots
    By sar_van81 in forum Qt Programming
    Replies: 7
    Last Post: 2nd April 2007, 12:31
  2. Signal and slots
    By villy in forum Qt Programming
    Replies: 1
    Last Post: 12th January 2007, 10:10
  3. Replies: 2
    Last Post: 17th May 2006, 21:01
  4. Emiting signal, which NOT connected to any slots
    By krivenok in forum Qt Programming
    Replies: 7
    Last Post: 27th February 2006, 16:32
  5. Problem with Signal and Slots
    By Kapil in forum Installation and Deployment
    Replies: 2
    Last Post: 10th February 2006, 08:51

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.