QSlider handle hides when changing groove background

I am trying to change the background image of a grove and set the image on a pen. At the same time, I was faced with a situation where the handle (which works) is covered with a groove at the moment when I set the background to anything. This simple example shows a problem when I change only the color and nothing else. The lip covers the pen with this little code. (user cannot slide right now) I missed something critical. What am I missing?

mySlider = new QSlider(centralWidget); mySlider->setObjectName(QStringLiteral("mySlider")); mySlider->setGeometry(QRect(960, 500, 100, 25)); mySlider->setOrientation(Qt::Horizontal); mySlider->setStyleSheet("QSlider::groove:horizontal {background-color:yellow;}"); 

Here is the slider:

enter image description here

+1
source share
1 answer

This seems like a mistake, it looks like the size of the handle has been resized to a size that makes it invisible, but if it can move with some difficulty. The last statement I checked with the following code.

  connect(mySlider, &QSlider::valueChanged, [=](int value){ qDebug()<<value; }); 

It is advisable to set the width and height, for example:

 mySlider->setStyleSheet("QSlider::groove:horizontal {background-color:yellow;}" "QSlider::handle:horizontal {background-color:blue; height:16px; width: 16px;}"); 

enter image description here

0
source

Source: https://habr.com/ru/post/1270225/


All Articles