Important: Please read the Qt Code of Conduct -

How to get access widgets placed on MainWindow's from QtScript

  • Hi All,

    I have created standard project from the template "Aplication->Qt Widgets Application" by Qt Creator.

    Now I need to get access to widgest placed on mainwindow.ui , so how I can did that ? My main goal change properties of object like QLable that is placed on mainwindow.ui through QtScript

    For example, code below shows how we can change properties directly while I need to change the properties of the elements are placed on the main form - mainwindow.ui

    QApplication a(argc, argv);
    QLabel lbl;
    QScriptEngine scriptEngine;
    QScriptValue scriptLbl = scriptEngine.newQObject(&lbl);
    scriptEngine.evaluate("lbl.text = 'Help me!'");


Log in to reply