Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    1
    1
    180
    Loading More Posts
    • 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.
    • Zholaman
      Zholaman last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • First post
        Last post