How to use Qt Gui Script in dialog box (example source calculator)

  • i want to use script gui.
    when click any special button, load special ui and connect script file.
    dynamically i want change ui, and script.

    in example source( calculater. path : qt path/examples/script/calculator)
    in main.cpp (no use dialog) it works well.
    but does not works well slot function in dialog box.

    the code is below....

    QScriptEngine engine;

    QString scriptFileName(":/calculator.js");
    QFile scriptFile(scriptFileName);;
    engine.evaluate(scriptFile.readAll(), scriptFileName);

    QUiLoader loader;
    QFile uiFile(":/calculator.ui");;
    QWidget *ui = loader.load(&uiFile);

    QScriptValue ctor = engine.evaluate("Calculator");
    QScriptValue scriptUi = engine.newQObject(ui, QScriptEngine::ScriptOwnership);
    QScriptValue calc = ctor.construct(QScriptValueList() << scriptUi);

    It does not showed calculator window in dialog box.
    If delete "QScriptValue scriptUi = engine.newQObject(ui, QScriptEngine::ScriptOwnership);" line,
    It shows calculator window, but does not work with script file.

    How can use QT Gui Script in dialog box ..

    please help me...

  • welcome to devnet

    Please use "code wrappings": for your posted code sections. This time I have introduced them for you.

Log in to reply

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