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] How to access styleData.value
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How to access styleData.value

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 3 Posters 2.0k Views 1 Watching
  • 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
    th.thielemann
    wrote on last edited by
    #1

    I defined the following TableView delegate:
    @
    itemDelegate:
    Rectangle {
    color: "#F2F2F2"
    border.color: "#cecece"
    height: 48
    Text {
    text: styleData.value
    }
    Component.onCompleted: console.log("Object item: styleData.value", styleData.value)
    }@

    The table is displaying the expected value. But console.log does not print it. What do I wrong here?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dasRicardo
      wrote on last edited by
      #2

      Hmm, correct me if i'm wrong but i think the onComplete need to be inside of text. Your Rectangle is complete but not your text. Like so:

      @
      itemDelegate:
      Rectangle {
      color: "#F2F2F2"
      border.color: "#cecece"
      height: 48
      Text {
      text: styleData.value
      Component.onCompleted: console.log("Object item: styleData.value", styleData.value)
      }
      }
      @

      **Sorry for my english :)

      PLEASE ADD [SOLVED] TO YOUR THREAD TITLE IF IT'S SOLVED.**

      1 Reply Last reply
      0
      • p3c0P Offline
        p3c0P Offline
        p3c0
        Moderators
        wrote on last edited by
        #3

        Hi,

        From the "Doc":http://qt-project.org/doc/qt-5/qml-qtquick-controls-tableview.html#itemDelegate-prop

        bq. Note: For performance reasons, created delegates can be recycled across multiple table rows. This implies that when you make use of implicit properties such as styledata.row or model, these values can change also after the delegate has been constructed. In practice this means you should not assume that content is fixed when Component.onCompleted happens, but instead rely on bindings to such properties.

        So the content might not be available as soon as the component gets completed and hence rely on the binding so that when the data gets available it gets reflected.

        157

        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