PDA

View Full Version : Creating custom scrollbars



Luc4
12th March 2010, 11:40
Hi! I'm trying to create a custom scrollbar. I subclassed QScrollBar and I overwrote the paint method. Seems to work quite ok, but I'm not able to make the cursor move correctly. I placed an ellipse this way:


painter.drawEllipse(0, this->height()*this->value()/(this->maximum() - this->minimum()) + 30,
this->width(), this->width());

for a vertical scrollbar. Unfortunately, seems not to scroll correctly according to the content of my area. Any other way?
Thanks!

toutarrive
12th March 2010, 11:42
By creating your own style (subclassing QStyle ) you will be able to define a custom drawing and behaviour for your scrollbar.

Luc4
12th March 2010, 12:34
Thanks for the advice. Anyway, seems very difficult to do it that way, isn't it possible to just use the same way I used, only adjusting the values?
Thanks!