Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-47539

TableViewStyle.qml: Unable to assign Object to QString

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.9.0 Beta 1
    • 5.5.0
    • Quick: Controls 1
    • None
    • Qt 5.5.0, Ubuntu 14.04
    • edc24e3cd75eaf02a587f50b14dbd0288447179d

    Description

      If setup role in TableViewColumn to "self" and declare custom delegate to column than we get run time error message:

      ".../qml/QtQuick/Controls/Styles/Desktop/TableViewStyle.qml:103:19: Unable to assign Object to QString"

      or

      ".../qml/QtQuick/Controls/Styles/Base/BasicTableViewStyle.qml:146:19: Unable to assign Object to QString"

      For example:

      TableViewColumn {
                  title: "Column1"
                  role: "self"
      
                  delegate: Text {
                      text: styleData.value.title + " " + styleData.value.author
                  }
              }
      

      In this example we want to show two object fields in one column, but we get run time error message.
      Full example code:

      import QtQuick 2.5
      import QtQuick.Controls 1.4
      
      ApplicationWindow {
          title: "TableView Test"
          width: 640
          height: 480
          visible: true
      
          TableView {
              anchors.fill: parent
      
              property QtObject book1: QtObject {
                  property string title: "A Masterpiece"
                  property string author: "Gabriel"
              }
      
              property QtObject book2: QtObject {
                  property string title: "Brilliance"
                  property string author: "Jens"
              }
      
              property QtObject book3: QtObject {
                  property string title: "Outstanding"
                  property string author: "Frederik"
              }
      
              model: [book1, book2, book3]
      
              TableViewColumn {
                  title: "Column1"
                  role: "self"
      
                  delegate: Text {
                      text: styleData.value.title + " " + styleData.value.author
                  }
              }
          }
      }
      

      Attachments

        For Gerrit Dashboard: QTBUG-47539
        # Subject Branch Project Status CR V

        Activity

          People

            Unassigned Unassigned
            ildar Gilmanov Ildar
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes