[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Range slider?
From:       David Boddie <david () boddie ! org ! uk>
Date:       2009-03-24 22:56:21
Message-ID: 200903242356.21959.david () boddie ! org ! uk
[Download RAW message or body]

On Mon Mar 23 02:02:51 GMT 2009, Hazen Babcock wrote:

> Does anyone know if a widget like this:
> http://www.codeproject.com/KB/miscctrl/CRangeSlider/CRangeSlider.gif
> exists for Qt?

There's a range slider of sorts included in the package mentioned here:

http://labs.trolltech.com/blogs/2009/03/23/embedded-widgets-source-code-released/

It's written in C++. I imagine it could be wrapped fairly easily with SIP
or ported to Python.

> This being the slider in the upper left corner of the 
> image which lets the user define a range or interval.
>
> If not, any suggestions on how to go about creating one?

You might start by subclassing QAbstractSlider to inherit the API:

http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qabstractslider.html

Drawing the slider might be a challenge - you could keep things simple to
start with and use simple drawing primitives, and later move on to use the
QStyle drawing API:

http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstyle.html

Handling mouse clicks and key events should be simple if you know enough
about the event model. Some of the examples provided with PyQt (Scribble,
Character Map) contain useful code that shows how to handle events, but the
examples themselves don't really address the same use case.

> I'm currently using to two sliders that are coupled to each other,
> one to set the high value and the other to set the low value, but I
> think this would be a lot cooler...

Yes, I agree. :-)

David
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic