How to embed label in lineedit?
or overlapping label above lineedit, so to look like the label is inside lineedit box?
see attached sceenshot
How to embed label in lineedit?
or overlapping label above lineedit, so to look like the label is inside lineedit box?
see attached sceenshot
Last edited by blonde; 1st December 2009 at 07:37. Reason: Add screenshot
Put the text in the lineedit with setText(). Subclass the lineedit and capture keypresses so you can filter out the keypresses (cursor left, home, backspace) that would move the cursor into the forbidden area.
with yogeshgokul's solution, the LineEdit's cursor starts from the beginning,
the user inputs covers the label, label acts as a background.
How can you make the curor starts after the label?
Because painting a QLineEdit with the blinking cursor is not as trivial as it seems for beginners... But after setting the label above the line edit just use QWidget::setContentsMargins() on the line edit (with the size of the label) and the label will stop to overlay the input text.
Ups, I've ment: QLineEdit::setTextMargins().
Bookmarks