I am writing an application in Qt, which uses QToolBar elements. In Linux and Windows, all looks OK. But in OS X, QToolBar have terrible gradient as its background. Please, suggest me, how I can remove it?
UPD.: I'm using Qt 5.2.
I am writing an application in Qt, which uses QToolBar elements. In Linux and Windows, all looks OK. But in OS X, QToolBar have terrible gradient as its background. Please, suggest me, how I can remove it?
UPD.: I'm using Qt 5.2.
Have you tried QStyleSheets?
http://qt-project.org/doc/qt-5/stylesheet-examples.html#customizing-qstatusbar
http://qt-project.org/doc/qt-5/stylesheet-reference.html#background-prop
QStatusBar * bar;
bar = new QStatusBar;
bar->setStyleSheet("background: transparent;");
// bar->setStyleSheet("background: none;");
// bar->setStyleSheet("background: white;");
bar->showMessage("StatusBar");
Or if you are using it in the context of a QMainWindow, it probably would look like:
this->statusBar()->setStyleSheet( //...
Hope that helps.
The way above with QStyleSheet is correct. Another approach is to apply for example QWindowsStyle object with setStyle to QToolBar. QWindowsStyle is something that will have simple and standard look on every platform. I use it when I would like to have look&feel exactly same on all platforms despite different looks&feels on win/mac/unx.
It seems toolbar ignores styleSheets on Mac at all (at least in Qt 5.2.1). I was able to remove the gradient using the styles, for example using the Windows style. Toolbar buttons are not affected with it.
toolBar->setStyle(QStyleFactory::create("windows"));
This is a known bug also in 2020 with Qt5.12 (and probably Qt5.15). What works is setting a border (which might be zero to your stylesheet):
QToolBar {
background-color: palette(base);
border-width: 0px;
}
background-color
alone does not seem to ensure that it's repainted.