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.globalObject().setProperty("lbl",scriptLbl);
    scriptEngine.evaluate("lbl.text = 'Help me!'");
    scriptEngine.evaluate("lbl.show()");
    

    Thanks!


Log in to reply
 

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