PDA

View Full Version : Edit Text of a QPushButton with mouse right click



theria05
8th December 2010, 15:56
Hi,

I'm new to Qt and I would like to be able to modify a QPushButton text with a mouse right click. I've created a subclass to handle right click, but I can't find any way to edit the text. I would apreciate any advice.

Thanks,

Olivier

tbscope
8th December 2010, 16:04
Signals and slots.
And a text input box

QtWannabe
8th December 2010, 16:04
Do you want to programmatically change the text or do you want the user to be able to specify the text? The latter is handled using the above posters method, the former is much more simple and can be seen below :



//inside right-click handling code
button->setText(desiredText)

theria05
8th December 2010, 16:41
Thanks for your replys. I want the user to change the text. I already handled the right click signal, but I don't know what to do with the "text input box"...

tbscope
8th December 2010, 17:09
With the text input box you ask for the new text.
When the user clicks ok, you set button text to the new text.

theria05
8th December 2010, 18:22
Ah k. Didn't think about a pop up. This can do the job. I was thinking about editing the text directly like it is done in a edit box, but maybe it is not necessary...

Thanks.

tbscope
8th December 2010, 18:49
You can show a line edit above the button, but I don't find this elegant.