Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

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

    General and Desktop
    2
    2
    1914
    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.
    • T
      tnak72 last edited by

      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);
      scriptFile.open(QIODevice::ReadOnly);
      engine.evaluate(scriptFile.readAll(), scriptFileName);

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

      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...
      thanks.~~

      1 Reply Last reply Reply Quote 0
      • K
        koahnig last edited by

        welcome to devnet

        Please use "code wrappings":http://qt-project.org/wiki/ForumHelp#e3f82045ad0f480d3fb9e0ac2d58fb01 for your posted code sections. This time I have introduced them for you.

        Vote the answer(s) that helped you to solve your issue(s)

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