Solved QSlider does not look as supposed to in QGraphicsProxyWidget
-
Hi,
I did this in my QGraphicsView:proxy = new QGraphicsProxyWidget(); zoomSlider = new QSlider(Qt::Vertical); QFile sliderStylesheetFile(":/CustomStylesheets/Slider_Stylesheet.txt"); sliderStylesheetFile.open(QIODevice::ReadOnly | QIODevice::Text); QString sliderStylesheet = sliderStylesheetFile.readAll(); zoomSlider->setStyleSheet(sliderStylesheet); zoomSlider->setGeometry(0, 0, 50, 150); proxy->setWidget(zoomSlider); scene->addItem(proxy); proxy->setPos(mapToScene(0, 0));
after that, I scale the proxy often, but this shouldn't affect the slider widget itself but except that, I'm not doing anything with the slider or the proxy.
But the slider looks like this:
It should look like this (I used the same stylesheet for both, but the following isn't in a QGraphicsProxyWidget):
If it helps, I use the following stylesheet:QSlider::groove:vertical { border: 1px solid #bbb; background: white; width: 10px; border-radius: 4px; } QSlider::sub-page:vertical { background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #fff, stop: 0.4999 #eee, stop: 0.5 #ddd, stop: 1 #eee ); border: 1px solid #777; width: 10px; border-radius: 4px; } QSlider::add-page:vertical { background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #78d, stop: 0.4999 #46a, stop: 0.5 #45a, stop: 1 #238 ); border: 1px solid #777; width: 10px; border-radius: 4px; } QSlider::handle:vertical { background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #eee, stop:1 #ccc); border: 1px solid #777; height: 13px; margin-top: -2px; margin-bottom: -2px; border-radius: 4px; } QSlider::handle:vertical:hover { background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #fff, stop:1 #ddd); border: 1px solid #444; border-radius: 4px; } QSlider::sub-page:vertical:disabled { background: #bbb; border-color: #999; } QSlider::add-page:vertical:disabled { background: #eee; border-color: #999; } QSlider::handle:vertical:disabled { background: #eee; border: 1px solid #aaa; border-radius: 4px; }
I am using Qt 5_9_1 and am running on Windows 10.
Any idea, what I have forgotten?
Thanks for answers! -
Hi,
You should add which version of Qt you are using as well as the platform you are running on.
-
Ok, with another stylesheet it works. But what is the mistake in the stylesheet I showed in the question?
-
Can you show the working stylesheet ?
-
Well, it's really really strange... I can't reproduce the problem now... I do exactely, what is pasted in the question and it works now... did restarting qt creator fix it in the end!? It is exactely the same project, but now it works