Results 1 to 6 of 6

Thread: QPushButton not calling repaint when needed?

  1. #1
    Join Date
    Aug 2007
    Posts
    27
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question QPushButton not calling repaint when needed?

    Me again

    I`m just trying to find out if this is a bug or not

    Ok, here it goes:

    I have QPushButtons on a QFrame and a stylesheet for the buttons for the normal state and the :hover state, the last adding a border-image to the button.
    Qt Code:
    1. image: url(:/images/userLocation.png);
    2. image-position: center center;
    3. border-image: url();
    4. }
    5. QPushButton:hover {
    6. border-image: url(:/images/button_active.png);
    7. }
    To copy to clipboard, switch view to plain text mode 

    All goes well untill I add a popup as a CustomContextMenu to the buttons, called with the customContextMenuRequested( const QPoint & ) signal.

    When the popup is called, it shows correctly but if I right-click on another one of these buttons, the popup goes away as it should, the second button gets hovered and the border-image is applied to it, but the first button never gets to unset it's border-image, and come back to it's display it should have when not hovered.
    In other words, i end up with two hovered-looking buttons.

    If I repeat the process and right click on the QFrame this time, it's the same thing, they both remain hovered, menu is gone.

    If I leave the QFrame with the mouse, the buttons get reset and go back to their normal look.

    After trying different approaches I tried giving the QPushButton that requested a context menu a repaint right when the popup is aboutToHide().

    It worked! Now when the popup hides, the old right-clicked QPushButton looks normal.

    Is this normal? Shouldn't this repaint get called automatically? That would sound logical to me.

    P.S.: I use a QPushButton* to remember which button requested a context menu, maybe qt doesn't and there for, does not know where to call repaint?

    Cheers!

  2. #2
    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 not calling repaint when needed?

    By the way, QToolButton has built-in menu support.
    J-P Nurmi

  3. #3
    Join Date
    Aug 2007
    Posts
    27
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Re: QPushButton not calling repaint when needed?

    Sorry, I don`t follow, what kind of menu support do you mean?

    And the context in which I`m using this is a QFrame having some buttons on it.

  4. #4
    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 not calling repaint when needed?

    You know, QToolButton can show a menu in three different ways; either with or without a delay or by pressing a special menu indicator. I just mean that this might be a bit more intuitive than using standard context menu which is quite rarely used for buttons I think. My apologies if this does not fit to the context. This was just a suggestion.

    As for the original problem, have you tried to examine the even flow? Does the problematic button for example ever receive a leave event? Try installing a few event filters and printing events and receivers to debug output.
    J-P Nurmi

  5. #5
    Join Date
    Aug 2007
    Posts
    27
    Qt products
    Qt4
    Platforms
    Unix/X11

    Thumbs up Re: QPushButton not calling repaint when needed?

    Thanks a lot for all the prompt responses

    Now, about this issue... I`ve already put it behind me... just called that repaint and did the job, I definitely think that the focusOut is not being fired there but I don't know when I`ll have the time or patience to test it again.

    And about the menu possibilities of QPushButton, thanx for the suggestions, I`ll give it a look, although the context menu seemed a straightforward approach

    Cheers.

  6. #6
    Join Date
    Aug 2009
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QPushButton not calling repaint when needed?

    Try setting Qt::WA_OpaquePaintEvent widget attribute for PushButton. It worked for me !!

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.