PDA

View Full Version : QGraphicsView and QScrollBar



paolom
1st October 2009, 16:28
Hi...

I've a QGraphicsView and I've set a custom scroll bar with setVerticalScrollBar().
It change the default scrollbar but I've two problem:

1) If I try to resize this scroll bar more than the default..half of it is hidden. I've tryed with many solution but I can't see all the new scroll bar.

2) Does anybody know a way to make it possible that If a user press with the mouse (and not whit keyboard PagDown or arrow keys) a scroll bar...this scroll bar can slide with a predefinite minimum value (and not for all the value of the slider)??!!

I want to make the same about press the Page Down key (set whit setSingleStep()) and the mouse that grab the scroll bar.

Thanks

scascio
1st October 2009, 21:06
It is hard work to replace the scrollbar since you have to respond to events and manage not only position, but the viewport size of your view.

Why do you want to replace the default one?

If you want to change its behaviour, you can always disable it and add additionnal widgets that control your graphics view using QGraphicsView::centerOn and QGraphicsView::fitInView

paolom
2nd October 2009, 00:33
Many thanks!! For the first question I've solved with the style sheet....

About the second question...does anybody tella a solution?

I want that when I drag with the mouse a scroll bar...this scroll bar doesn't move 1 to 1 but with a minimum size....

I hope that my issue is clear...

thanks

wysota
2nd October 2009, 08:19
1) If I try to resize this scroll bar more than the default..half of it is hidden. I've tryed with many solution but I can't see all the new scroll bar.
You need to use QAbstractScrollArea::setViewportMargins() to inform the widget about new margins it should leave for your scrollbar.


2) Does anybody know a way to make it possible that If a user press with the mouse (and not whit keyboard PagDown or arrow keys) a scroll bar...this scroll bar can slide with a predefinite minimum value (and not for all the value of the slider)??!!
Override mousePressEvent().