Results 1 to 3 of 3

Thread: Slot never called

  1. #1
    Join Date
    Jun 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Slot never called

    I have following code:
    Qt Code:
    1. class MyProxy : public QObject
    2. {
    3. Q_OBJECT
    4. public:
    5. MyProxy() : QObject()
    6. {
    7.  
    8. }
    9. public slots:
    10. void ButtonPress2()
    11. {
    12. emit SIGNAL(Change());
    13. }
    14. void Changed()
    15. {
    16. QMessageBox::information(0, "Changed","Changed");
    17. }
    18. signals:
    19. void Change();
    20. };
    To copy to clipboard, switch view to plain text mode 

    ButtonPress2() is being called from button's clicked() signal, however Changed() slot is never called.

    Sorry, I'm absolutely newbie in QT...

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Slot never called

    Nothing in your code calls connect() to connect a signal to the Changed() slot or call it directly.
    If you want the button to trigger only the Changed() slot then simply connect the button triggered() signal directly to the Changed() slot.

    Line 12 might compile but it does not have the intended effect. You want:
    Qt Code:
    1. emit Change();
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jun 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Slot never called

    I called connect(), but error was in emit call, so this works:
    Qt Code:
    1. emit Change();
    To copy to clipboard, switch view to plain text mode 

    Thanks a lot!!!

Similar Threads

  1. Replies: 2
    Last Post: 26th August 2011, 08:51
  2. Slot doesn't get called
    By waynew in forum Qt Programming
    Replies: 7
    Last Post: 18th April 2010, 13:34
  3. How come this slot doesn't get called every second?
    By ShaChris23 in forum Qt Programming
    Replies: 2
    Last Post: 5th November 2009, 23:41
  4. Slot gets called twice
    By greatgatsby in forum Newbie
    Replies: 7
    Last Post: 20th August 2009, 15:11
  5. SLOT not being called
    By steg90 in forum Qt Programming
    Replies: 4
    Last Post: 6th December 2007, 11:30

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.