Results 1 to 1 of 1

Thread: Re: How to change the colour of a pushbutton when disabled[SOLVED]

  1. #1
    Join Date
    Aug 2011
    Posts
    35
    Thanks
    5

    Default Re: How to change the colour of a pushbutton when disabled[SOLVED]

    I have 2 pushButtons. The following code disables a pushButton when clicked and enables the other one. I would like to change the colour of the pushButtons when they are disabled(to gray). How do I do this? Any help would be appreciated.

    Qt Code:
    1. void wave::on_pushButton_clicked()
    2. {
    3. //Generate
    4. thread->start();
    5. ui->pushButton->setEnabled(false);
    6. ui->pushButton_2->setEnabled(true);
    7. }
    8.  
    9. void wave::on_pushButton_2_clicked()
    10. {
    11. //Terminate
    12. thread->terminate();
    13. ui->pushButton_2->setEnabled(false);
    14. ui->pushButton->setEnabled(true);
    15.  
    16. }
    To copy to clipboard, switch view to plain text mode 


    Added after 12 minutes:


    got it actually:
    Qt Code:
    1. void wave::on_pushButton_clicked()
    2. {
    3. //Generate
    4. freq = ui->frequency->text().toDouble();
    5. ampl = ui->amplitude->text().toDouble();
    6. thread->start();
    7. ui->pushButton->setEnabled(false);
    8. ui->pushButton->setStyleSheet("background-color: gray");
    9. ui->pushButton_2->setStyleSheet("background-color: rgb(255, 192, 192)");
    10. ui->pushButton_2->setEnabled(true);
    11. }
    12.  
    13. void wave::on_pushButton_2_clicked()
    14. {
    15. //Terminate
    16. thread->terminate();
    17. ui->pushButton_2->setEnabled(false);
    18. ui->pushButton_2->setStyleSheet("background-color: gray");
    19. ui->pushButton->setStyleSheet("background-color: rgb(192, 255, 208);");
    20. ui->pushButton->setEnabled(true);
    To copy to clipboard, switch view to plain text mode 
    }
    Last edited by duma; 15th August 2011 at 19:09.

Similar Threads

  1. Change the colour of a table view row
    By Splatify in forum Newbie
    Replies: 0
    Last Post: 7th March 2011, 06:31
  2. Change the colour of a QT TextEdit row
    By Splatify in forum Newbie
    Replies: 3
    Last Post: 3rd March 2011, 14:09
  3. change the text colour in Menubar
    By chinmayapadhi in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2010, 01:31
  4. How to change Text colour in EditText?
    By phillip_Qt in forum Qt Programming
    Replies: 6
    Last Post: 6th March 2008, 08:48
  5. Change colour of QString
    By Morea in forum Newbie
    Replies: 9
    Last Post: 10th February 2006, 22:31

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
  •  
Qt is a trademark of The Qt Company.