Results 1 to 2 of 2

Thread: qml qnd c++ integration

  1. #1
    Join Date
    Aug 2010

    Default qml qnd c++ integration

    I have developed my whole GUI using QT qml. I have a lot of qml files and the flow is like that I am loading any new qml file from another qml file using page_loader... Now I want to integrate qml with c++ so that from c++ I will be able to change any qml properties.. I have used this code to integrate qml with c++:-

    QDeclarativeView view;

    ApplicationData data;
    view.rootContext()->setContextProperty("applicationData", &data);

    QGraphicsObject *rootObject = dynamic_cast<QGraphicsObject*>(view.rootObject());;

    return app.exec();

    Now to change any property of qml file I added objectName in that qml file and then accessed that object from c++ using this code

    QGraphicsObject *rect = rootObject->findChild<QGraphicsObject*>("mainText");
    if (rect){
    rect->setProperty("text", "Came here");

    here "mainText" object name of one of the text element in the PasswordMain.qml file....

    Till now its working and I am able to change any property of the file which I have set as a source in c++ code but the problem is that if I want to change any property of the page loaded from this PasswordMain.qml file then I am not able to change that using same process.... I am not getting any idea of how to change the properties of loaded qml page from c++.Please help me in this regard......Thanks in advance........

  2. #2
    Join Date
    Jan 2006
    Warsaw, Poland
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits

    Default Re: qml qnd c++ integration

    I think you need to repeat the whole process after the other file is loaded.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.

Similar Threads

  1. VS Integration
    By GrahamLabdon in forum Qt Programming
    Replies: 3
    Last Post: 25th March 2010, 09:06
  2. Eclipse Integration sans Integration
    By ChrisW67 in forum Qt Tools
    Replies: 3
    Last Post: 17th March 2009, 08:29
  3. VS.NET integration
    By invictus in forum Installation and Deployment
    Replies: 1
    Last Post: 15th May 2008, 07:49
  4. integration help
    By chap19150 in forum Qt Programming
    Replies: 7
    Last Post: 24th July 2006, 18:00
  5. Qt Integration
    By ToddAtWSU in forum Newbie
    Replies: 4
    Last Post: 23rd January 2006, 18:54

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.