accessing attributes of qml elements from c++
-
how to access predefined attributes of qml elements from c++......for example,in my case how to access mouseX,mouseY of mousearea from c++ file......
-
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).....
-
ok ok....now that error has gone but i am getting (0,0) at each and every position.....any reason???
-
Do you have "hoverEnabled" property set to true? If not, mouse is not being tracked, and you'll get (0,0) every time.