PDA

View Full Version : Highlight and edit an entire QDateTimeEdit?



kja
23rd November 2010, 22:44
Hi,

Can anyone give me some tips on where to look to make a QDateTimeEdit completely highlighted and editable? I want the user to be able to type in some numbers without having to use the arrow keys to move between the YYYY MM DD HH MM SS fields.

Thanks!

BalaQT
24th November 2010, 08:51
hi,

to make a QDateTimeEdit completely highlighted

u can use stylesheets to change the color of the QDateTimeEdit

ex:

d->setStyleSheet("background-color:blue;color:white");


completely highlighted and editable?

what do u mean by editable?


I want the user to be able to type in some numbers without having to use the arrow keys to move between the YYYY MM DD HH MM SS fields.

I didnt get ur point. pls explain ur need clearly.

Thnks
Bala

wysota
24th November 2010, 08:55
Use a QLineEdit with a validator or an input mask.

kja
29th November 2010, 19:05
Thanks a lot!

I ended up using a validator and it works great:



startEdit->setInputMask("xxxx/xx/xx xx:xx:xx");
QRegExp reg("([1-2* ][ 0-9*][ 0-9*][ 0-9*])/([0-1* ][ 0-2*]|[0*][ 0-9*])/([0-3* ][ 0-1*]|[0-2* ][ 0-9*]) [0-2* ][ 0-9*]:[*0-5 ][ \\d*]:[*0-5 ][ \\d*]");
QValidator *val = new QRegExpValidator(reg, this);
startEdit->setValidator(val);


Thanks for the help!