[PyKDE] Custom QScrollBar'ed widgets

Gordon Tyler gordon at doxxx.net
Fri Sep 3 16:05:25 BST 2004


Sundance wrote:

> Thank you, but this won't do. I'd need to attach the scrollbar to a 
> custom widget, *not all* of which will scroll, hence making QScrollView 
> useless for this case. Basically, instead of a viewport, the widget 
> would have a QVBox containing several subwidgets, the actual viewport 
> being only one of those.

So these other subwidgets stay still while this one other widget needs 
to scroll? I feel cross-eyed already ;)

So why don't you just wrap this one subwidget in a scrollview?

> I don't know if overriding the viewport can be done directly, so I've 
> tried going for another approach, where I manually attach an 
> independant QScrollBar to my custom widget. But I still need to know 
> how to sync the scrollbar to the widget's viewport. :)

Not having done anything like that before, all I can suggest is that you 
read the docs for the QScrollBar class:

http://doc.trolltech.com/3.3/qscrollbar.html

If your scrolling subwidget has a custom paintEvent handler, then maybe 
you can tie the scrollbar's value to a y-offset that's applied to all 
the drawing operations in the paintEvent handler?

Reading the QScrollView C++ source may give you some ideas as well.

Ciao,
Gordon




More information about the PyQt mailing list