Results 1 to 3 of 3

Thread: QT4 signal/slot

  1. #1
    Join Date
    Jan 2006
    Location
    Grenoble, France
    Posts
    165
    Thanks
    106
    Qt products
    Qt4
    Platforms
    Windows

    Default QT4 signal/slot

    In the following code the SLOT(Ok()) is not triggered when the user presses the pushbutton Ok. I have either to put "accept" or "close". As it is here the window is not closed or only with cancel

    I don't understand this behaviour, what have I done wrong ?

    Qt Code:
    1. pbOk = new QPushButton( "Ok", this);
    2.  
    3. connect( pbOk, SIGNAL( clicked() ), this, SLOT( Ok() ) ); // <--- does not work
    4. connect( pbCancel, SIGNAL( clicked() ), this, SLOT( close() ) );
    5.  
    6. }
    7.  
    8. //*************************************************************
    9. void Destinataires::Ok()
    10. {
    11. accept(); // does not work either with emit accept, emit close
    12. close();
    13. }
    To copy to clipboard, switch view to plain text mode 

    Thanks for helping me out !

  2. #2
    Join Date
    Jan 2006
    Location
    Grenoble, France
    Posts
    165
    Thanks
    106
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT4 signal/slot

    I forgot to add "private slots:" in the class declaration. All works well. Sorry.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QT4 signal/slot

    How about just:

    Qt Code:
    1. connect( pbOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
    2. connect( pbCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
    To copy to clipboard, switch view to plain text mode 

  4. The following user says thank you to wysota for this useful post:

    incapacitant (23rd March 2006)

Similar Threads

  1. Passing a pointer in Signal/Slot Connection
    By mclark in forum Qt Programming
    Replies: 4
    Last Post: 6th November 2007, 19:04
  2. QTableWidget signal/slot question
    By twells55555 in forum Qt Programming
    Replies: 8
    Last Post: 6th August 2007, 21:58
  3. What argument types for Signal/Slot?
    By DPinLV in forum Qt Programming
    Replies: 5
    Last Post: 2nd August 2006, 19:08
  4. What if not Signal/Slot
    By munna in forum General Discussion
    Replies: 2
    Last Post: 26th May 2006, 06:48
  5. Replies: 4
    Last Post: 23rd January 2006, 16: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.