2
votes

I have this QML code and its really straight forward but my problem is the onEntered and onExited does not work at all. I do not see anything wrong with the code and I feel it is a QtQuick bug !

import QtQuick 2.2

Rectangle {
    width: 480
    height: 320
    Rectangle {
        x: 30; y: 30
        width: 300; height: 240
        color: "lightsteelblue"

        MouseArea {
            anchors.fill: parent

            hoverEnabled: true

            onEntered: {
                console.log('mouse over ya kbeer');
            }

            onExited: {
                console.log('mouse out ya kbeer');
            }
        }
    }
}

I use this as a qml component to be used in other place. am not sure but maybe because I have to embed them inside another Qt Quick items the mouse events does not reach this item because it has been cached by the parent am not sure of that !

Any suggestions and help is really appreciated !

2
How do you use this rectangle QML item? if you use it inside another QML item, which hover enabled too, then it eats the mouse events first and that's why you don't see any received event. - Max Go
yes I use it inside another item, but am not using the mouse hover on the upper item, and its catchs the onClicked but not onEntered - Creative Coder
well, for some reasons the mouse events is not get propagated to your inner element. I suggest you one by one to put MouseArea in parents elements and find out what last parent element receives the mouse event ... and think why it doesn't propagate it. - Max Go
I think i found the issues, take a look at my answer if you could help me in that I will be appreciated - Creative Coder

2 Answers

1
votes

Resources are built into your executable. If you want to change them, you need to rebuild the exe.

You can try add new QML file by Add new - Qt - QML file: write here your code (using Qt Quick) but load it to your QQuickView by view->setSource(QUrl::fromLocalFile("fullpath.qml")); When you finish your app, write this file to resource and use resource path.

0
votes

I found the issues is not on the code or qml but on the QCreator itself, when I update my qml code since it is in the resources and when I click on run it does not take the latest update. now after I rebuild it its works fine. But does anyone knows why this happens !