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. [SOLVED] QML Qt.createQmlObject how to refer variable

[SOLVED] QML Qt.createQmlObject how to refer variable

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

    Hi all. I have a QML & JavaScript code:
    @ Grid {
    columns: 4
    y: 50
    id: grid
    spacing: 50
    function pokaz() {
    for(var j = 0; j < 5; j++) {
    Qt.createQmlObject('import com.nokia.meego 1.1; Label {text: wydatek.nazwa(j)}', grid, '');
    Qt.createQmlObject('import com.nokia.meego 1.1; Label {text: wydatek.cena(j)}', grid, '');
    Qt.createQmlObject('import com.nokia.meego 1.1; Label {text: wydatek.sztuk(j)}', grid, '');
    Qt.createQmlObject('import com.nokia.meego 1.1; Label {text: wydatek.data(j)}', grid, '');
    }
    }
    Component.onCompleted: pokaz();
    }@
    I can't to refer 'j' value. I have a log:
    @ <Unknown File>:1: ReferenceError: Can't find variable: j@
    Question is: How can I refer the 'j' value? How I do wrong?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @
      'import com.nokia.meego 1.1; Label {text: wydatek.nazwa(' + j + ')}'
      @

      (Z(:^

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

        Thanks:)

        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