Results 1 to 4 of 4

Thread: Highlight and edit an entire QDateTimeEdit?

  1. #1
    Join Date
    Oct 2010
    Posts
    58
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    26

    Default Highlight and edit an entire QDateTimeEdit?

    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!

  2. #2
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 47 Times in 43 Posts

    Default Re: Highlight and edit an entire QDateTimeEdit?

    hi,
    to make a QDateTimeEdit completely highlighted
    u can use stylesheets to change the color of the QDateTimeEdit

    ex:
    Qt Code:
    1. d->setStyleSheet("background-color:blue;color:white");
    To copy to clipboard, switch view to plain text mode 

    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

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Highlight and edit an entire QDateTimeEdit?

    Use a QLineEdit with a validator or an input mask.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Oct 2010
    Posts
    58
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    26

    Default Re: Highlight and edit an entire QDateTimeEdit?

    Thanks a lot!

    I ended up using a validator and it works great:

    Qt Code:
    1. startEdit->setInputMask("xxxx/xx/xx xx:xx:xx");
    2. 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*]");
    3. QValidator *val = new QRegExpValidator(reg, this);
    4. startEdit->setValidator(val);
    To copy to clipboard, switch view to plain text mode 

    Thanks for the help!

Similar Threads

  1. QTableView line edit clears the text on edit
    By PlasticJesus in forum Qt Programming
    Replies: 5
    Last Post: 14th March 2015, 20:06
  2. QDateTimeEdit
    By doberkofler in forum Qt Programming
    Replies: 8
    Last Post: 2nd November 2009, 16:10
  3. QDateTimeEdit
    By doberkofler in forum Newbie
    Replies: 0
    Last Post: 28th October 2009, 07:28
  4. Character encoding in text edit and llne edit
    By greenvirag in forum Qt Programming
    Replies: 3
    Last Post: 20th January 2009, 09:45
  5. QDateTimeEdit
    By dkite in forum Qt Programming
    Replies: 2
    Last Post: 10th September 2006, 20:12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.