PDA

View Full Version : Custom QScrollBar problem



PinTxO
17th March 2017, 15:13
Hi everyone.

I have my own QStyle class that initially was responsible only to visualize the slider, not the movement arrows (up, down, left and right). These were not being drawn.
Now I have to modify it to display those arrows. I have managed to make them look but I have a problem with the area where the slider is deployed. It seems that the area is still the innicial, without arrows, so if I move the slider, it slides the arrows.
What I have done and I do not understand why it does not work is in the QStyle :: subControlRect method, the QStyle :: SC_ScrollBarGroove subcontrol, modify the rectangle so that it takes into account the squares of the arrows.
After this change the slider continues to cover the arrows, the only thing that has changed is that the slider, being in the minimum value, if I move with the mouse, it takes just the size of the square of the arrow.

My code in QStyle :: subControlRect method (rectangle of the arrows buttons is 16x16):


case SC_ScrollBarGroove:
if (scrollbar->orientation == Qt::Horizontal)
result.setRect(16, 0, scrollbar->rect.width()-32, scrollbar->rect.height());
else
result.setRect(0, 16, scrollbar->rect.width(), scrollbar->rect.height()-32);
break;

Any ideas?