Results 1 to 6 of 6

Thread: QPushButton gets stuck drawing pressed when transfer of focus to button interrupted

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QPushButton gets stuck drawing pressed when transfer of focus to button interrupt

    If the user types in the control and then clicks the button the messagebox pops but the button gets stuck being drawn looking like it’s pressed. How can I make that stop?
    The reason for this is that you are calling you message box in a modal state with exec().
    This causes the applications even loop to wait for the message box to be dismissed, and therfore, the paintEvent for the pushbuttons is not being handled until the message box is not dismissed.
    What you can do is:
    1. Rethink your design. If the user is shifting input focus from a control, when the application logic states that this should not be allowed, its better to force the focus to stay on the focused control than to send a message box.
    You could in addition to forcing the focus, have somewhere a message saying why it is being done, similar to what many applications do in the status bar.
    2. Show the message box with show() and not exec(), but then it wont be modal, can be covered by other windows, and can bring to that that it will be immediately covered by another window so that the user not even notice it was popped.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  2. #2
    Join Date
    Nov 2010
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QPushButton gets stuck drawing pressed when transfer of focus to button interrupt

    Got it answered here without having to resort to either option (unless something comes up in the future but seems to work so far): http://stackoverflow.com/questions/4...tton-is-interr

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QPushButton gets stuck drawing pressed when transfer of focus to button interrupt

    if it works for you - Great!
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  4. #4
    Join Date
    Nov 2010
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QPushButton gets stuck drawing pressed when transfer of focus to button interrupt

    Well we haven’t made all the dialogs yet nor run through all the testing so something could come up. I’m still fairly new to Qt but the only potential problem I see is something getting between the creation of a user QEvent in test_line_edit::focusOutEvent and it getting processed in test_line_edit::customEvent. Do you know if that’s possible? Seems like it might be but I don’t really know under what conditions… Also are there any other obvious problems with this approach that I might be missing?

  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QPushButton gets stuck drawing pressed when transfer of focus to button interrupt

    Well, again, you can bend anything and force anything.
    But I still think that the problem is a design problem, not an implementation problem.
    You can work around design problem by forcing stuff, but then you are on slippery road of surprises.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Replies: 4
    Last Post: 16th September 2011, 02:10
  2. Replies: 6
    Last Post: 4th October 2010, 03:19
  3. QPushButton gets stuck
    By mhoover in forum Qt Programming
    Replies: 1
    Last Post: 22nd May 2010, 23:22
  4. Qt/Mac - Stuck with user focus
    By sergant in forum Qt Programming
    Replies: 1
    Last Post: 24th January 2009, 08:56
  5. Replies: 3
    Last Post: 26th September 2006, 12:16

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.