Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

To call function in C++ from QML

$
0
0
I am trying to call destructor from qml. I dont know how to call it Here is the simple code what I tried to call constructor myitem.h class MyItem : public QDeclarativeItem {     Q_OBJECT   public:     explicit MyItem(QDeclarativeItem *parent = 0);    ~MyItem(); }; myitem.cpp MyItem::MyItem(QDeclarativeItem *parent): QDeclarativeItem(parent) { .... }   MyItem::~MyItem() { } main.cpp int main(int argc, char *argv[]) {     QApplication a(argc, argv);       qmlRegisterType<MyItem>("mywindow",1,0,"MyItem");       QDeclarativeView view;     view.setSource(QUrl("main.qml"));     view.showMaximized();     return a.exec(); } main.qml import QtQuick 1.1 import mywindow 1.0   Item {     id:item_id     Rectangle{         x:100         y:100         MyItem{           }       } }

Viewing all articles
Browse latest Browse all 18427

Trending Articles