Quantcast
Viewing all articles
Browse latest Browse all 13965

How to resolve the QObject errors

I wrote the following code to assign image source runtime . //main.h class Main : public QQuickView { Q_OBJECT public: static Main *instance(); void mousePressEvent(QMouseEvent* m); //void keyReleaseEvent(QKeyEvent* e); void setup(); static QObject *rootObject; static QObject *image; int lock_value; static QStringList lockimage; private: explicit Main(); }; //main.cpp main instance () { QDeclarativeView* view = NULL; view->setSource(QUrl::fromLocalFile(“main.qml”)); rootObject = dynamic_cast<QObject *>(view->rootObject()); //rootObject = (QObject *)view->rootObject(); // find element by name image = rootObject->findChild<QObject *>(QString(“status_locked_img”)); } display instance () { image->setProperty(“source”, QString(“images/image1.png”)); } //main.qml Rectangle { id:status_locked color: “black” width: 10; height:10 x:8;y:6 property int type : lock_status Image { objectName: status_locked_img visible: true } I am getting error while building “ error: C2681: ‘QGraphicsObject *’ : invalid expression type for dynamic_cast” please help me in resolving this error

Viewing all articles
Browse latest Browse all 13965

Trending Articles