Results 1 to 3 of 3

Thread: Incorporating if-else statement with QPushButton

  1. #1
    Join Date
    Dec 2015
    Posts
    6
    Qt products
    Qt5
    Platforms
    Windows

    Default Incorporating if-else statement with QPushButton

    Hi guys, anyone know how to incorporate QPushButton into if-else statment?
    I am using connect function for my program.
    I do not know how to let the QPushButton work if it is clicked.

    Qt Code:
    1. iampushbutton = new QPushButton;
    2.  
    3. if(iampushbutton->_____?______ )
    4. {
    5. function1();
    6. }
    7. else
    8. {
    9. function2();
    10. }
    To copy to clipboard, switch view to plain text mode 
    Stop resisting and surrender to the dark forces

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Incorporating if-else statement with QPushButton

    What is it that you want to check?
    I.e. what should the if condition mean?

    Cheers,
    _

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Incorporating if-else statement with QPushButton

    I am using connect function for my program.
    If you are using a connect() statement with the correct syntax and you have correctly implemented the slot to handle the button's clicked() signal, then your slot is being called when the button is clicked. You implement the code for what happens next inside the slot method.

    If you don't understand that, then you need to study the example and tutorial programs that came with your Qt distribution and read about signals and slots. There are dozens of examples of how push buttons and their signals are used.

Similar Threads

  1. Replies: 5
    Last Post: 7th March 2014, 19:37
  2. IF-Statement problem
    By ayanda83 in forum Newbie
    Replies: 2
    Last Post: 18th November 2013, 08:02
  3. How to get value from a query statement ?
    By hohoanganh205 in forum Newbie
    Replies: 3
    Last Post: 5th January 2012, 14:23
  4. Replies: 0
    Last Post: 22nd February 2010, 09:30
  5. Replies: 3
    Last Post: 26th September 2006, 12:16

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.