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. Mouse events
Qt 6.11 is out! See what's new in the release blog

Mouse events

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.2k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    molto_bravo
    wrote on last edited by
    #1

    Hi guys,

    I found the example below on this site and I tried to modify it so I can play animations on mouse enter and exit events. The problem is when the mouse hovers over the different keys, the animations start/stop as expected. However, if I press the mouse left button key down then I drag the mouse around while holding the mouse button down, the animation stops when I leave the button area and does not start when I enter a different button area. My guess is that has to do with the original button still capturing the mouse and it is obvious because when I bring the mouse pointer back to the original button (where I originally pressed the mouse button down), the mouse down animation works fine. I'd like to figure out 1) if this is considered a mouse drag and move event? and 2) is there a way to fix this by forcing a mouse release in qml? 3) If the answer to my last question is no, then how can I do it on a Rectangle object in C++?

    Thanks in advance for your help.

    @Rectangle {
    id: content
    anchors.fill: parent
    radius: style.but_outer_radius
    smooth: true
    color: demoConstants.uiLightGrey

        KeyLabel
        {
            id: text_label_en
            text: button_pane.label_en
            state: "active"
            cstyle: button_pane.style
        }
        KeyLabel {
            id: text_label_other
            text: button_pane.label_other
            state: "inactive"
            cstyle: button_pane.style
        }
    
        Timer{
            id: autoRepeatTimer
            interval: autoRepeatInterval
            running: false
            repeat: true
    
            onTriggered: button_pane.sigButtonPressed( button_pane.currentKey())
        }
    
        MouseArea {
            hoverEnabled: true
    
            anchors.fill: parent
    
            onClicked:
            {
                button_pane.sigButtonPressed (button_pane.currentKey());
    
                mouse_btn_down_animation.stop();
                mouse_btn_up_animation.start();
            }
    
            onEntered:
            {
                mainWindow.sigOnMouseEnter(button_pane); )
    
                mouse_btn_up_animation.stop();
                mouse_btn_down_animation.start();
            }
    
            onExited:
            {
                mainWindow.sigOnMouseLeave(button_pane);
                mouse_btn_down_animation.stop();
                mouse_btn_up_animation.start();
                
                button_pane.border.color = style.col_but_border
                autoRepeatTimer.running = false;
            }
    
            onReleased:
            {
                mouse_btn_down_animation.stop();
                mouse_btn_up_animation.start();
                autoRepeatTimer.running = false;
            }
    
            onPressed:
            {
                mouse_btn_up_animation.stop();
                mouse_btn_down_animation.start();
            }
    
            onPressAndHold:
            {
                autoRepeatTimer.running = button_pane.autoRepeat;
            }
        }@
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      molto_bravo
      wrote on last edited by
      #2

      Bumping this topic to top hoping that someone will be able to help answer my questions.

      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