Results 1 to 4 of 4

Thread: QPushButton setText problem

  1. #1
    Join Date
    Jun 2008
    Posts
    64
    Thanks
    7
    Qt products
    Qt3 Qt4

    Default QPushButton setText problem

    I am having a Q3ButtonGroup with some QPushButton.

    I want to update the text of the button when it is being clicked.
    Hence I used setText() to perform what I want.
    However I found that the setText() doesn't update the ui.
    I mean, when I use text() to cout the text of the button, I found that the new text is actually already be set, but in the user interface, I found that it doesn't update at all!!!!
    I tried to call all those thing like update()/repaint() after calling the setText but it still doesn't work.

    Can anyone tell me what's going on?
    Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Thanks
    30
    Thanked 13 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QPushButton setText problem

    Calling setText on a QPushButton should update the text onscreen with no need to call repaint/update

    Could you make a minimal compilable example program that has the problem and post it here?

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

    Default Re: QPushButton setText problem

    Perhaps you block the event loop with a busy loop. As long as your function is executing, Qt has no chance to update the buttons.
    J-P Nurmi

  4. The following user says thank you to jpn for this useful post:

    batileon (3rd December 2008)

  5. #4
    Join Date
    Jun 2008
    Posts
    64
    Thanks
    7
    Qt products
    Qt3 Qt4

    Default Re: QPushButton setText problem

    Thanks!
    Seems it is really related to the event loop. By adding
    Qt Code:
    1. QApplication::processEvents();
    To copy to clipboard, switch view to plain text mode 
    I solved the problem.

Similar Threads

  1. QPixmap in QPushButton size problem
    By MarkoSan in forum Qt Programming
    Replies: 3
    Last Post: 22nd January 2008, 12:50
  2. Problem with QLabel and setText
    By jambrek in forum Qt Programming
    Replies: 7
    Last Post: 31st October 2007, 16:02
  3. QPushButton problem
    By sincnarf in forum Qt Programming
    Replies: 4
    Last Post: 20th August 2007, 21:02
  4. Problem with QLineEdit and setText
    By Elmo23x in forum Qt Programming
    Replies: 8
    Last Post: 12th April 2007, 12:35
  5. QPushbutton problem
    By amulya in forum Qt Programming
    Replies: 5
    Last Post: 30th August 2006, 08:11

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.