View Full Version : clear button for line edit
jayreddy
2nd December 2009, 05:30
Hii all..
Can I know how to add a clear button to a QLineEdit ?
Thank You
Jayakrishna Reddy
aamer4yu
2nd December 2009, 06:58
Check this - Lineedit with Clear Button (http://labs.trolltech.com/blogs/2007/06/06/lineedit-with-a-clear-button/)
zgulser
2nd December 2009, 07:01
Hi, I guess you have a designer. If so, just add a button from the designer and just connect it to a slot as the following;
connect( yourClearButton,
SIGNAL(clicked()),
this,
SLOT(clearButtonClickedSlot()) );
and just implement the SLOT
void Foo::clearButtonClickedSlot()
{
mUi->yourLineEdit->setText("");
}
spirit
2nd December 2009, 07:07
Hi, I guess you have a designer. If so, just add a button from the designer and just connect it to a slot as the following;
connect( yourClearButton,
SIGNAL(clicked()),
this,
SLOT(clearButtonClickedSlot()) );
and just implement the SLOT
void Foo::clearButtonClickedSlot()
{
mUi->yourLineEdit->setText("");
}
in this case you can simply use one connection
connect( yourClearButton,
SIGNAL(clicked()),
mUi->yourLineEdit,
SLOT(clear()) );
;)
but I think author needs clear-button like aamer4yu suggested.
zgulser
2nd December 2009, 08:02
Oh I didn't know the clear thing..you're right.
By the way, right about the last comment of yours as well I guess.
jayreddy
2nd December 2009, 12:48
Sorry..that is not the case. I am asking about how to add a clear button to a QLineEdit using cascading style sheets. So that I can display the clear button on the lineedit in the hover state.
aamer4yu
3rd December 2009, 04:36
You will need to make your custom widget.
Also the link I gave before,, the code link seems to be invalid now...:(
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.