accessing attributes of qml elements from c++
QML and Qt Quick
5
Posts
2
Posters
3.2k
Views
1
Watching
-
It's all explained in the documentation. Basically, you have to extract your MouseArea object from rootContext, and then get the property value using the Meta Object System.
Here's on of relevant docs: "link":http://developer.qt.nokia.com/doc/qt-4.8/qtbinding.html#exchanging-data-between-qml-and-c.
-
@QObject *mousearea=rect->findChild<QObject *>("mouse");
qDebug()<<"position:"<<mousearea->property("mouseX").toDouble()<<","<<mousearea->property("mouseY").toDouble();@this is what i wrote........but when i am executing the code i ma getting don't send error(i am in windows by the way).....
-
Do you have "hoverEnabled" property set to true? If not, mouse is not being tracked, and you'll get (0,0) every time.