×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Aug 2009
    Posts
    331

    How to call Widget function from QML?

    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:

    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();
    }
    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?

    Please guide.

    Thanks.

  2. #2
    Regular Contributor
    Join Date
    Mar 2012
    Posts
    144

    Re: How to call Widget function from QML?

    you can always use signals and slots. check qml <-> c++ communications in docs

Similar Threads

  1. Phone call in widget
    By Egisto in forum Symbian Web Runtime
    Replies: 1
    Last Post: 2010-01-29, 17:19
  2. Symbian API to call a call back function
    By sai_kumar in forum Symbian C++
    Replies: 2
    Last Post: 2009-01-28, 16:42
  3. (Bluetooth) RSocket Write function does not call RunL function
    By ronald29 in forum Symbian Networking & Messaging (Closed)
    Replies: 13
    Last Post: 2008-10-14, 10:58
  4. Execption manipulate when C++function call C function
    By zhangpengstu in forum Open C/C++
    Replies: 1
    Last Post: 2008-05-28, 11:09
  5. Exception when C++ function call C function
    By zhangpengstu in forum Symbian C++
    Replies: 4
    Last Post: 2008-05-27, 10:03

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •