Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Bug or feature: Hover-highlighting isn't reset if a QDialog is shown by a widget being hover-highlighted
Forum Update on Monday, May 27th 2025

Bug or feature: Hover-highlighting isn't reset if a QDialog is shown by a widget being hover-highlighted

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 635 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • l3u_L Offline
    l3u_L Offline
    l3u_
    wrote on last edited by
    #1

    Hi :-)

    This is probably some speacial case, so I'm not sure if what I see is only unexpected behavior or a bug.

    I use a QRadioButton derived class which catches right mouse clicks. When being clicked by the right mouse button, the radio button is selected as if it was clicked by the left button, but additinally, a QDialog derived dialog is shown. I achieve this with the following code (stripped down to the relevant parts) inside my QRadioButton class:

    void BoogerRadioButton::mousePressEvent(QMouseEvent *event)
    {
        if (event->button() == Qt::RightButton) {
            if (! isChecked()) {
                setChecked(true);
                emit clicked();
            }
            emit scoreDialogRequested();
        } else {
            QRadioButton::mousePressEvent(event);
        }
    }
    

    The scoreDialogRequested signal triggers the dialog to be shown. The result is that the highlighting set by the mouse cursor hovering the radio button stays until the cursor re-enters the button and leaves it again. Here's a screenshot:

    0_1541271567760_highlight.png

    As a workaround, I call QWidget::mouseMoveEvent with a QMouseEvent taking part one pixel outside of the widget after emitting the signal triggering the dialog to show up, which makes the highlighting go away. Like this:

    QMouseEvent ev(QEvent::MouseMove, QPointF(-1.0, -1.0), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
    mouseMoveEvent(&ev);
    

    So … is this a bug or a feature?! ;-)

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mpergand
      wrote on last edited by mpergand
      #2

      Usely, the button is selected on mouse release and only if the mouse cursor is still inside the button.
      On mouse press, the button is only highlighted.
      You go against standard behavior and so the issue you describe

      l3u_L 1 Reply Last reply
      1
      • l3u_L Offline
        l3u_L Offline
        l3u_
        wrote on last edited by
        #3

        Okay, so I should reimplement the mouseReleaseEvent rather than the mousePressEvent? I'll try that. I surely don't want to code against the default behavior.

        1 Reply Last reply
        0
        • M mpergand

          Usely, the button is selected on mouse release and only if the mouse cursor is still inside the button.
          On mouse press, the button is only highlighted.
          You go against standard behavior and so the issue you describe

          l3u_L Offline
          l3u_L Offline
          l3u_
          wrote on last edited by l3u_
          #4

          @mpergand Using mouseReleaseEvent instead of mousePressEvent actually fixes the highlight problem, thanks for the hint!

          1 Reply Last reply
          0
          • l3u_L Offline
            l3u_L Offline
            l3u_
            wrote on last edited by
            #5
            This post is deleted!
            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved