Results 1 to 3 of 3

Thread: QLineEdit and background text

  1. #1

    Default QLineEdit and background text

    All-

    I've got a QLineEdit that is used to specify a file path for either Windows or Unix environments. I've got a QRegExpValidator to ensure things are entered correctly, but to a new user, the format it accepts may be non-obvious -- when they start typing and nothing happens, it'd be rather confusing.

    I'd like to write, in the text-entry space, a brief statement of what format the QLineEdit is accepting, eg "Insert Windows filename here", but not as the value of QLineEdit (e.g., not via setText(..)).

    My thoughts were to use a QPainter and drawText into this space when the text() was empty (and the widget is enabled) in a light-colored font (as to not confuse, but rather inform, the user). This text would be more obvious than a tooltip.

    I've tried to re-implement paintEvent directly and use QCoreApplication::sendEvent() with a QPaintEvent object that defines the rect() of the QLineEdit to no avail.

    Can anyone provide some hints as to how to get this working, or suggest an alternative technique?

    Thanks!

    SnarlCat

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QLineEdit and background text

    Quote Originally Posted by SnarlCat View Post
    I've tried to re-implement paintEvent directly and use QCoreApplication::sendEvent() with a QPaintEvent object that defines the rect() of the QLineEdit to no avail.
    Hmm, what was the problem with paintEvent()? It should work... I don't understand what is QCoreApplication::sendEvent() needed for, though.
    J-P Nurmi

  3. #3

    Default Re: QLineEdit and background text

    *grumble*

    Chalk this one up to RTFM(better)..

    Sorry for the noise..

    SnarlCat

Similar Threads

  1. Changing text colour of QLineEdit qss file
    By phillip_Qt in forum Qt Programming
    Replies: 2
    Last Post: 4th April 2008, 05:28
  2. prob with changing QLineEdit background color
    By Ahmad in forum Qt Programming
    Replies: 2
    Last Post: 30th April 2007, 12:44
  3. background color of QLineEdit
    By Seema Rao in forum Qt Programming
    Replies: 4
    Last Post: 11th December 2006, 20:40

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.