Results 1 to 7 of 7

Thread: Edit Text of a QPushButton with mouse right click

  1. #1
    Join Date
    Dec 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Edit Text of a QPushButton with mouse right click

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Edit Text of a QPushButton with mouse right click

    Signals and slots.
    And a text input box

  3. #3
    Join Date
    Jun 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Edit Text of a QPushButton with mouse right click

    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 :

    Qt Code:
    1. //inside right-click handling code
    2. button->setText(desiredText)
    To copy to clipboard, switch view to plain text mode 
    Last edited by QtWannabe; 8th December 2010 at 16:09.

  4. #4
    Join Date
    Dec 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Edit Text of a QPushButton with mouse right click

    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"...

  5. #5
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Edit Text of a QPushButton with mouse right click

    With the text input box you ask for the new text.
    When the user clicks ok, you set button text to the new text.

  6. #6
    Join Date
    Dec 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Edit Text of a QPushButton with mouse right click

    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.

  7. #7
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Edit Text of a QPushButton with mouse right click

    You can show a line edit above the button, but I don't find this elegant.

Similar Threads

  1. QTableView line edit clears the text on edit
    By PlasticJesus in forum Qt Programming
    Replies: 5
    Last Post: 14th March 2015, 19:06
  2. Replies: 3
    Last Post: 26th August 2010, 08:57
  3. Replies: 7
    Last Post: 26th August 2009, 07:21
  4. Character encoding in text edit and llne edit
    By greenvirag in forum Qt Programming
    Replies: 3
    Last Post: 20th January 2009, 08:45
  5. Replies: 8
    Last Post: 15th May 2007, 09:21

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.