Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qt Quick Button' hovered is true event if it's disabled
Qt 6.12 LTS is out! See what's new in the release blog

Qt Quick Button' hovered is true event if it's disabled

Scheduled Pinned Locked Moved QML and Qt Quick
15 Posts 2 Posters 11.5k 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.
  • p3c0P Offline
    p3c0P Offline
    p3c0
    Moderators
    wrote on last edited by
    #2

    Hi,

    Which Qt Version/OS are you using ?

    157

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Tân Ngọc Đỗ
      wrote on last edited by
      #3

      Hello,

      I'm using 5.4.0

      1 Reply Last reply
      0
      • p3c0P Offline
        p3c0P Offline
        p3c0
        Moderators
        wrote on last edited by
        #4

        That's strange, it works on Ubuntu 14.04 with Qt 5.3.2
        Tried the following code
        @
        Item {
        id: window
        width: 320
        height: 480

        Button {
            id: button;
            enabled: false
            text: "hover here"
            MouseArea {
                anchors.fill: parent
                hoverEnabled: true
                onEntered: {
                    console.log("entered")
                }
            }
        }
        

        }
        @

        Can you try the above ?

        157

        1 Reply Last reply
        0
        • T Offline
          T Offline
          Tân Ngọc Đỗ
          wrote on last edited by
          #5

          Hello,
          Actually your sample code runs well even if I do not use MouseArea.
          In my case, some time it's happened. I also have binding loop with "hovered" property of button

          1 Reply Last reply
          0
          • p3c0P Offline
            p3c0P Offline
            p3c0
            Moderators
            wrote on last edited by
            #6

            and how do you do it without MouseArea ? Sorry I didnt get a chance to use Qt 5.4 yet. Does it have any new added signals ?

            157

            1 Reply Last reply
            0
            • T Offline
              T Offline
              Tân Ngọc Đỗ
              wrote on last edited by
              #7

              You can use "hovered" as a read-only property of button. It's a built-in property and you don't need to define a MouseArea, if you define a MouseArea you can not use some Button property and its signal . These feature belongs to QtQuick Button before 5.4 . You can refer : http://doc.qt.io/qt-5/qml-qtquick-controls-button.html

              There is also one signal: clicked() . It's more convenient for user than defining a MouseArea

              Thanks

              1 Reply Last reply
              0
              • p3c0P Offline
                p3c0P Offline
                p3c0
                Moderators
                wrote on last edited by
                #8

                Hmm these were present in Qt 5.3.2
                I tried the following new code as per it
                @
                Item {
                id: window
                width: 320
                height: 480

                Button {
                    id: button;
                    enabled: false
                    text: "hover here"
                }
                
                Timer {
                    interval: 500; running: true; repeat: true
                    onTriggered: console.log(button.hovered)
                }
                

                }
                @

                Keeping enabled to false; prints false on timeout. And when enabled set to true, true or false gets printed as expected on hover.

                157

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  Tân Ngọc Đỗ
                  wrote on last edited by
                  #9

                  Yes, It runs ok with 5.4 . Maybe my problem relates to binding loop of "hovered" .

                  1 Reply Last reply
                  0
                  • p3c0P Offline
                    p3c0P Offline
                    p3c0
                    Moderators
                    wrote on last edited by
                    #10

                    Ok. Can you post the related code then which produces the problem ?

                    157

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      Tân Ngọc Đỗ
                      wrote on last edited by
                      #11

                      Well I create a PlayBar.qml : there are 4 buttons in this files and I used a user-defined property : "isHovered" as a result of "hovered" on those 4 buttons :
                      @
                      //PlayBar.qml:
                      ToolBar {
                      id:toolBar
                      readonly property bool isHovered: ( btnNextFrame.hovered || btnPlayStop.hovered || btnPrevFrame.hovered
                      || btnNextMovie.hovered || btnPrevMovie.hovered) )
                      ..........................................................

                      //Main.qml:
                      ApplicationWindow {

                      PlayBar {
                      id: playBar
                      }

                      property bool hovered: playBar.isHovered

                      }
                      @

                      I receive a message :"Binding loop for "isHovered" in PlayBar.qml

                      1 Reply Last reply
                      0
                      • p3c0P Offline
                        p3c0P Offline
                        p3c0
                        Moderators
                        wrote on last edited by
                        #12

                        Well I was not able to produce the "Binding Loop" error from above code. But it could possibly be due to the same.

                        157

                        1 Reply Last reply
                        0
                        • T Offline
                          T Offline
                          Tân Ngọc Đỗ
                          wrote on last edited by
                          #13

                          When I roll-back to 5.3.2 there are no problem with "binding loop" and the button is not hovered when it is disable . It's very strange!!!

                          1 Reply Last reply
                          0
                          • p3c0P Offline
                            p3c0P Offline
                            p3c0
                            Moderators
                            wrote on last edited by
                            #14

                            Then it could be a bug in Qt 5.4. Please report it on "Qt bug tracker":https://bugreports.qt-project.org/

                            157

                            1 Reply Last reply
                            0
                            • T Offline
                              T Offline
                              Tân Ngọc Đỗ
                              wrote on last edited by
                              #15

                              Well, I will reproduce the problem for clearer description on bug tracker.

                              Anyways, thank you very much for your help!

                              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
                              • Unsolved