Hello all,
I wang to communicate between Widget and Qml. I have created my own widget derived from QWidget. In main I have written the following code:
As per the code the qml contents are appended in MyWidget. So I am getting Qml contents + the button as expected as output. Now i just wanted to display the message defined in MyWidget class through Qml. Is it possible to do that?Code:int main(int argc, char *argv[]) { QScopedPointer<QApplication> app(createApplication(argc, argv)); QDeclarativeView *declView = new QDeclarativeView; declView->setSource(QUrl::fromLocalFile("sample.qml")); //qmlRegisterType<MyWidget>("myWidget", 1, 0, "MyWidget"); QWidget *widget = new MyWidget(); QVBoxLayout *layout = new QVBoxLayout(widget); if (declView) layout->addWidget(declView); QPushButton *btn = new QPushButton(widget); btn->setText("Test Button"); layout->addWidget(btn); widget->show(); return app->exec(); }
Please guide.
Thanks.

Reply With Quote

