Results 1 to 2 of 2

Thread: QLineEdit shadow text disappear on first entry

  1. #1
    Join Date
    Oct 2007
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QLineEdit shadow text disappear on first entry

    Hi!

    I am trying to achieve a "shadow text" in QLineEdit: ie. a text that is displayed within widget only until a user enters a first character (please see attachment). After that foreground color should change to default/black and "shadow text" should be replaced by contents given by user.

    I've created a private slot "editTextChanged(QString)" in my QDialog-derived class that is connected to QLineEdit's textChanged() signal.

    I've tried to use isModified() but when I get the notification to editTextChanged() the isModified is already true.

    I cannot use setFocus() signal since this is the main widget of the window that gains focus immediately after showing the dialog.

    What would be the best way to achieve such functionality?
    Using QT4.4

    Thank you!
    -Marcin
    Attached Images Attached Images

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

    Default Re: QLineEdit shadow text disappear on first entry

    In my opinion, focus in/out events would definitely be the best choices. Just like Opera's address bar and search box use them. As soon as they gains focus, the help text is hidden. As soon as they lose focus, the help text is shown again but only if nothing was entered, of course.
    J-P Nurmi

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. QLineEdit text() crash - Qt3
    By user_mail07 in forum Qt Programming
    Replies: 7
    Last Post: 10th June 2008, 09:42
  3. Pointer Question related to QLineEdit
    By ChrisReath in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2008, 15:13

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.