Trolltech Home | Qt-jambi-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-jambi-interest Archive, February 2008
Implement custom data models for spinners


Message 1 in thread

Hello!

I wonder if somebody can show me an example of how I can implement a 
custom datamodel for a QSpinBox. I have a set of valid numbers that the 
spinner should jump between when it is stepped up and down, and the 
valid number are NOT in a continuous range.

Regards,
Helge Fredriksen


Message 2 in thread

Helge Fredriksen wrote:
> Hello!
> 
> I wonder if somebody can show me an example of how I can implement a 
> custom datamodel for a QSpinBox. I have a set of valid numbers that the 
> spinner should jump between when it is stepped up and down, and the 
> valid number are NOT in a continuous range.

Hi Helge,

QAbstractSpinBox has some virtual methods stepBy and validate which you 
should be able to reimplement to get the behaviour you need.

http://doc.trolltech.com/qtjambi-4.3.3_01/com/trolltech/qt/gui/QAbstractSpinBox.html#stepBy(int)
http://doc.trolltech.com/qtjambi-4.3.3_01/com/trolltech/qt/gui/QAbstractSpinBox.html#validate(com.trolltech.qt.gui.QValidator.QValidationData)

-
best regards,
Gunnar