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. Qt Quick Designer - JS binding

Qt Quick Designer - JS binding

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qt quickparsingbindingjavascript
2 Posts 1 Posters 1.3k 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.
  • OkynO Offline
    OkynO Offline
    Okyn
    wrote on last edited by
    #1

    Hi,

    I was wondering if it is possible in Qt Quick Designer (so in design mode, not in edit mode) to add a Js Binding on a property ?

    An example :

    I have a JS file named globals.js containing variables :

    var myvar1 = 1
    var myvar2 = 2
    ....
    

    I import this file in my qml file

    import "global.js" as Global
    

    When I am in design mode in Qt Quick Designer I would like to be able to have access to this file an the variables when I add a binding on an item.
    indeed, when I add a binding on a button, "Global" is not in the combo box of "Source Item" and consequently variables of the js file are not in the combo box of "Source Property" (I would like to have myvar1, myvar2, .. here).

    Is there an easy way to do it ?

    I tried to find in the source code of qt creator where the js file is parsing and where the list of variables are stored but I didn't succeed.. My goal was to extend qt creator to fill those combo box..

    Thank you.

    1 Reply Last reply
    0
    • OkynO Offline
      OkynO Offline
      Okyn
      wrote on last edited by
      #2

      I have found a workaround but I am still open with a better idea..

      I have modify this source file of qt creator "src/plugins/qmldesigner/qmldesignerextension/connectioneditor/bindingmodel.cpp"
      I added the field "Global" in "Source Item" and when Global is selected in souce item I read my js file and with a regexp I add variables in "Source Property"

      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