Results 1 to 7 of 7

Thread: QPushButton SetText

  1. #1
    Join Date
    Dec 2009
    Location
    New Zealand
    Posts
    54
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    23

    Default QPushButton SetText

    Hi, I am trying to change the text displayed on a button as soon as the button is clicked.

    I can change it fine by using SetText, but, it only shows the updated text after everything else in the slot has been completed.

    What could I use to update the buttons text 'instantly'?

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

    Default Re: QPushButton SetText

    Do you use the mouse press event ?

  3. #3
    Join Date
    Dec 2009
    Location
    New Zealand
    Posts
    54
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    23

    Default Re: QPushButton SetText

    Hi, Thanks, no Im not using mousePressEvent. I cannot find how I could use mousePressEvent to help me.

    Is there a command I can write that will update the button/GUI instantly? I have tried a few but none of them seem to do the trick.
    Last edited by Ferric; 26th October 2010 at 08:59.

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: QPushButton SetText

    change the text at the beginning of the slot and call e.g. QCoreApplication::processEvents(). Or do everything else in a thread.

  5. The following user says thank you to Lykurg for this useful post:

    Ferric (26th October 2010)

  6. #5
    Join Date
    Dec 2009
    Location
    New Zealand
    Posts
    54
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    23

    Default Re: QPushButton SetText

    Thank You, using QCoreApplication::processEvents() works well. Using a thread is a little over my head at this stage.

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QPushButton SetText

    Quote Originally Posted by Ferric View Post
    Thank You, using QCoreApplication:rocessEvents() works well. Using a thread is a little over my head at this stage.
    Try resizing the window while "everything else" works or move some other window over the window of your application. See if this is something you really want for your users.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #7
    Join Date
    Dec 2009
    Location
    New Zealand
    Posts
    54
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    23

    Default Re: QPushButton SetText

    I know what you are saying Wysota.. My application is not as professional as it could be. One day I will hopefully find the time to comprehend using threads.

Similar Threads

  1. QPushButton setText Alignment
    By rokkamraja in forum Qt Programming
    Replies: 2
    Last Post: 19th October 2009, 11:44
  2. QPushButton SetText Color
    By Qt Coder in forum Qt Programming
    Replies: 1
    Last Post: 13th April 2009, 18:21
  3. QPushButton setText problem
    By batileon in forum Qt Programming
    Replies: 3
    Last Post: 3rd December 2008, 04:02
  4. QPushButton - setText with "\n" not working
    By gboelter in forum Newbie
    Replies: 7
    Last Post: 10th February 2008, 04:27

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
  •  
Qt is a trademark of The Qt Company.