[PyKDE] Re: QScrollBar, fixed width
Patrick Stinson
patrickkidd at gmail.com
Wed Mar 22 20:02:36 GMT 2006
I got a reply from qt-interest regarding this. What is the state of QStyle
sub-classes in pyqt4? is there a reason that they are not included?
Thanks. The qt-interest reply follows:
At 09:34 07.03.2006, you wrote:
>How do I set the width of a QScrollBar in a QScrollArea. calling
>scrollarea->verticalScrollBar()->setFixedWidth(100) seems to have no
>effect. thanks!
>
>-P
>
>www.patrickkidd.com
>
>--
>To unsubscribe - send a mail to qt-interest-request at xxxxxxxxxxxxx
>with "unsubscribe" in the subject or the body.
>List archive and information: http://lists.trolltech.com/qt-interest/
Hi Patrick,
Try this:
- Define an own style in a class derived from a QStyle
=> e.g.
MyStyle : public QWindowsStyle
- Define length and width
=> e.g.
#define SCROLLBARWIDTH
- Override the method pixelMetric()
=> e.g.:
int pixelMetric(PixelMetric metric, const QStyleOption *, const
QWidget *pWidget = 0) const
{
if ( metric == PM_ScrollBarExtent )
{
return SCROLLBARWIDTH
}
return QWindowsStyle::pixelMetric( metric, 0, pWidget );
}
}
- Then set the style to the Scrollbar in your code.
=> e.g. mystyle = new MyStyle();
verticalScrollBar()->setStyle( mystyle );
Andrea
On 3/2/06, Patrick Stinson <patrickkidd at gmail.com> wrote:
>
> I am trying to set the width of a vertical scrollbar (or any for that
> matter) of a QScrollArea. I use PyQt4, kde-3.5.1, and the default plastic
> syle. The size prints 50 for each scrollbar, but the width does not change.
> Ideas? thanks in advance.
>
> from PyQt4.QtGui import *
> from PyQt4.QtCore import *
>
> a = QApplication([])
> scroll = QScrollArea()
> w = QWidget()
> w.setFixedSize(2000,2000)
> scroll.setWidget(w)
>
> bar = scroll.verticalScrollBar()
> bar.setFixedWidth(50)
> print bar.width()
>
> bar = scroll.horizontalScrollBar()
> bar.setFixedWidth(50)
> print bar.width()
>
> scroll.show()
> a.exec_()
>
>
> --
> Patrick Kidd Stinson
> http://pkaudio.sourceforge.net/
> http://pksampler.sourceforge.net/
>
--
Patrick Kidd Stinson
http://www.patrickkidd.com/
http://pkaudio.sourceforge.net/
http://pksampler.sourceforge.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20060322/1fc859c0/attachment.html
More information about the PyQt
mailing list