[Qt-interest] Background color of QToolBar

Russ Loucks rjl at third-monday.com
Thu Oct 28 00:27:05 CEST 2010


I am trying to set the background color of a QToolBar.  This newsgroup 
does have a couple of threads of how to do this but I can't really get 
any of them to work.

Environment:
- Qt 4.7
- Linux FC 11
- gcc 4.4.1

I've tried the following without success:

class InstrumentPanel : public QMainWindow {
     InstrumentPanel::InstrumentPanel() {
         mainToolBar = addToolBar (tr("main"));

         QPalette p (mainToolBar->palette());
         p.setColor(QPalette::Window, Qt::blue);
         mainToolBar->setPalette(p);
         mainToolBar->setAutoFillBackground(true);

         // I've also tried QPalette::Background and
         // Button

         // Also tried:

         mainToolBar->setStyleSheet("background: blue;");
         mainToolBar->setAutoFillBackground(true);
     }
}

Using the palette for this has no effect.

Using the stylesheet for this sets the background color of the buttons I 
add (as QActions).

Ideas?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101027/d55c17b1/attachment.html 


More information about the Qt-interest-old mailing list