Solved Setting QLinearGradient with Stylesheet always shows Black
-
i have a new Project with Qt 5.9.5 on Linux. Everything is very new, except the Linux Installation. In the Project i want to use a Gradient for a QToolBar, but everything i tried doesnt work. When i set a normal Color with "background-color: blue;" then it works. But every LinearGradient Option shows always a Black Background.
Normally i use the set Stylesheet Option from QT Creator, but i also tried it with ->setStyleSheet() in Code.
This is what i have now.
QToolBar { background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 1,stop: 0 white, stop: 0.4 gray,stop: 1 green); }
-
@Fuel-0
Hi. I tried your gradient on my toolbar (although I am testing it on Win10, Qt 5.10.1), and it seems to work correctly.ui->mainToolBar->setStyleSheet("QToolBar {\ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 1,stop: 0 white, stop: 0.4 gray,stop: 1 green);}");
Do other uses of gradient work on your system? e.g. the Qt example
https://doc.qt.io/qt-5.10/qtwidgets-painting-gradients-example.html -
i dont know why it works now, but i dont use the Designer now. I created my QToolBar in the Source and use setStyleSheet().