Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML objects accesible in QtScript?

QML objects accesible in QtScript?

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 4.6k 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.
  • R Offline
    R Offline
    rikardo
    wrote on last edited by
    #1

    We would like to write our application i a way that we define our UI front end with QML language (some QML components/items will be written in C++ to provide desired functionality), then we would like to access all this QML objects from javascript in QtScript.

    The goal we are trying to achieve is to develop the whole app and it's logic in javascript (QtScript). And allow developers not to bother with QML. So basically old school programming but with QML behind it to master the UI frontend.

    So as a developer I would execute the following script (example):

    var root = app.getRootQMLWidget();
    var sideBar = new QMLSideBar();
    sidebar.anchors.left = root.left;
    sidebar.anchors.top = root.top;
    sidebar.anchors.bottom = root.bottom;
    sidebar.width = 200;

    var list = new QMLMultiColumnList();
    // setting some properties on list
    list.anchors.fill = root;
    ...

    So this javascript code should dynamically build QML elements.

    Also one unrelated question, where can I find more info/docs on QSS?

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

      I've been able to do lot of things with qss, just from what documentation was available in the Qt docs, http://doc.trolltech.org/4.7-snapshot/stylesheet-syntax.html

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mbrasser
        wrote on last edited by
        #3

        I don't think the model above can be done, but even it were possible it's not really a good fit for how QML was designed, and I think you'll lose a lot (if not all) of the advantages of QML in trying to develop this way (for example object.property = foo.bar in javascript performs an assignment, and doesn't establish a binding).

        That said, you should still be able to code application logic in script -- see for example the samegame or calculator demos in which all of the logic is implemented in script. The script will need to be coded in a "QML friendly" way though; for example you'll need to use the "dynamic object management":http://doc.qt.nokia.com/4.7-snapshot/qdeclarativedynamicobjects.html functionality provided by QML.

        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