Changes to the QML object in the QT Widgets Application



  • Can I change the properties of the QML object in the application in "QT widgets Application" (during the program)?
    So far, I did as in the given code:

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);

    connect(ui->pushButton, SIGNAL(clicked()), qApp, SLOT(quit()));
    
    QQuickView *view = new QQuickView();
    QWidget *container = QWidget::createWindowContainer(view, this);
    container->setMinimumSize(200, 200);
    container->setMaximumSize(200, 200);
    container->setFocusPolicy(Qt::TabFocus);
    view->setSource(QUrl("/home/newuser/widgetsandqml/main.qml"));
    ui->verticalLayout->addWidget(container);
    

    QObject *item = view->rootObject();
    item->setProperty("width",500);
    }
    I would like to change the property in the QML file after pressing "Button"
    If you can do that, please, for example.

    Regards


  • Lifetime Qt Champion

    Hi,

    You should take a look at the Overview - QML and C++ Integration chapter in Qt's documentation.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.