Results 1 to 4 of 4

Thread: set QProgressDialog. progress indicator color?

  1. #1
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default set QProgressDialog. progress indicator color?

    how to set QProgressDialog. progress indicator color?

  2. #2
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: set QProgressDialog. progress indicator color?

    Do you mean the progress bar on the QProgressDialog? If so, you can set its palette Highlight color to the color you want.

    Maybe QProgressDialog constructs the progress bar with a default bar. To replace it just create a new QProgressBar* , change its color and replace it with setBar ( QProgressBar * bar )

    Qt Code:
    1. QProgressBar * myBar = new QProgressBar(this);
    2.  
    3. QPalette palette1;
    4. QBrush brush2(QColor(192, 0, 0, 255)); //Some red color
    5. brush2.setStyle(Qt::SolidPattern);
    6. palette1.setBrush(QPalette::Active, QPalette::Highlight, brush2);
    7. palette1.setBrush(QPalette::Inactive, QPalette::Highlight, brush2);
    8. QBrush brush3(QColor(204, 199, 197, 255));
    9. brush3.setStyle(Qt::SolidPattern);
    10. palette1.setBrush(QPalette::Disabled, QPalette::Highlight, brush3);
    11. myBar->setPalette(palette1);
    12.  
    13. MyProgressDialog.setBar(myBar);
    To copy to clipboard, switch view to plain text mode 

    Carlos

  3. #3
    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: set QProgressDialog. progress indicator color?

    You can use a style sheet

  4. #4
    Join Date
    Mar 2012
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: set QProgressDialog. progress indicator color?

    Carlos, I tried what you suggested in a class that is derived from QProgressBar. This is my code:
    Qt Code:
    1. void MyProgressBar::onStarted()
    2. {
    3. setFormat(tr("Preparing"));
    4.  
    5. QPalette p = this->palette();
    6. QBrush greenBrush(QColor(0, 255, 0, 255));
    7. greenBrush.setStyle(Qt::SolidPattern);
    8. p.setBrush(QPalette::Active, QPalette::Highlight, greenBrush);
    9. p.setBrush(QPalette::Inactive, QPalette::Highlight, greenBrush);
    10. this->setPalette(p);
    11. }
    To copy to clipboard, switch view to plain text mode 
    But the color doesn't change. Maybe you can spot my mistake?

Similar Threads

  1. Busy Indicator using QProgressDialog??
    By qtzcute in forum Qt Programming
    Replies: 13
    Last Post: 6th September 2011, 11:31
  2. Using a QFrame as a color selection indicator
    By KShots in forum Qt Tools
    Replies: 8
    Last Post: 14th June 2011, 23:55
  3. Replies: 0
    Last Post: 16th December 2010, 15:04
  4. Replies: 4
    Last Post: 11th March 2008, 11:44
  5. qprogressDialog
    By mickey in forum Qt Programming
    Replies: 5
    Last Post: 17th July 2006, 14:16

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.