Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to use Qt Gui Script in dialog box (example source calculator)
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.0k Views
  • 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 Offline
    T Offline
    tnak72
    wrote on last edited by
    #1

    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
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      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
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved