Results 1 to 4 of 4

Thread: Will QPushButton::setChecked(true); change my Icon?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Will QPushButton::setChecked(true); change my Icon?

    I'm working on button properties similar to Start/Pause & Stop.
    The scenario is like this:
    1. Two Buttons: Start/Pause & Stop which is related to a process
    2. On click of play, pause icon is shown and Stop button is enabled.
    3. On click of pause, start icon is shown, and stop button is enabled.
    4. I get one signal from other process - start: pause icon is shown & stop button should be enabled.

    My button properties are like this
    Qt Code:
    1. m_pbScan = new QPushButton(this);
    2. m_pbScan->setIcon(QIcon(":/imgs/scanStart.png"));
    3. m_pbScan->setCheckable(true);
    4. connect(m_pbScan, SIGNAL(clicked(bool)), this, SLOT(onScanBtnClicked(bool)));
    5.  
    6. // SLOT:
    7. void CStatusPage::onScanBtnClicked(bool click)
    8. {
    9. qDebug() << click;
    10. if(click)
    11. {
    12. emit scanBtnClicked();
    13. m_pbScan->setIcon(QIcon(":/imgs/scanPause.png"));
    14. }
    15. else
    16. {
    17. m_pbScan->setIcon(QIcon(":/imgs/scanStart.png"));
    18. emit pauseBtnClicked();
    19. }
    20. m_pbScanStop->setEnabled(true);
    21. }
    To copy to clipboard, switch view to plain text mode 

    When I get a signal from some other event promptin for start, then I'm calling this function -
    Qt Code:
    1. void CStatusPage::scanOn()
    2. {
    3. m_pbScan->setChecked(true);
    4. }
    To copy to clipboard, switch view to plain text mode 

    My doubt is, will the setChecked(true); automatically invoke connect and set icon to pauseIcon?
    I trying to implement a logic that works with above mentioned scenarios.
    Thank you.
    Last edited by rawfool; 19th June 2013 at 10:56.

Similar Threads

  1. QPushButton::setEnabled( true ) not working
    By unshaven in forum Newbie
    Replies: 1
    Last Post: 9th August 2012, 06:27
  2. Replies: 1
    Last Post: 28th May 2010, 16:59
  3. QPushButton - Only show the Icon
    By graciano in forum Newbie
    Replies: 9
    Last Post: 19th September 2009, 21:15
  4. QPushButton Icon Image
    By QbelcorT in forum Qt Programming
    Replies: 3
    Last Post: 13th March 2009, 14:26
  5. setchecked( true) of the radio button doesn't work
    By richardander in forum Qt Programming
    Replies: 9
    Last Post: 28th January 2009, 17:54

Tags for this Thread

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.