PDA

View Full Version : QValidator and ListWidget



csvivek
26th June 2008, 14:53
Hi ,
I am using Qt4.3.4 and i am using QIntValidator for validating the Inputs of Line Edits.
The Same Code when i was using with Qt4.2.2 was working. Can Anyone tell where the problem is ...?

I Also Wanted to know if it is possible to Set Keyboard Shortcuts to each item in a ListWidget.


--
Thanks in advacne.

aamer4yu
26th June 2008, 15:46
I Also Wanted to know if it is possible to Set Keyboard Shortcuts to each item in a ListWidget.

Well, you can capture keyPressEvent for the list widget. And based ont he key pressed, set the corresponding item as selected, or whatever operation u want :)

other way is to create actions and set shortcut for them. And on each action perform some operation,,,

but I guess capturing keyPressEvent would be better :)

csvivek
3rd July 2008, 05:16
My Another question was this.....

I have used QIntValidator to validate lineedits,


QIntValidator *min_vldtr;

the above code is a part of class declaration....



min_vldtr=new QIntValidator(MIN_SEC,MAX_SEC,this);
m_reg.lelatmin->setValidator(min_vldtr);


this is a class that inherits QObject and m_reg is the object for the class generated by the UIC....the above code is a part of the class constructor.

this code works fine with Qt4.2.2 but the same code when i compiled with Qt4.2.2 the Validator performs in a weird manner. The Lineedit accepts only number as inputs but the range is not getting set properly.
Can anyone suggest a solution for this problem

wysota
3rd July 2008, 07:32
Could you post a minimal compilable example reproducing the problem?

csvivek
9th July 2008, 19:19
you can see the qt example....

widgets/lineedits/
from the Qt installation folder...

there the validator is not working as per the code for QDoubleValidator.