Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Changes to the QML object in the QT Widgets Application

Changes to the QML object in the QT Widgets Application

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 519 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pirates21
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved