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. TableView rendering issue on Windows 7
Forum Updated to NodeBB v4.3 + New Features

TableView rendering issue on Windows 7

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qt quickqmlqt 5.3tableview
3 Posts 1 Posters 1.8k 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.
  • M Offline
    M Offline
    Monomix
    wrote on 11 Mar 2015, 15:36 last edited by A Former User
    #1

    Howdy all,

    I'm experiencing an interesting quirk of a dynamically-populated TableView in a QML app; when the associated QAbstractTableModel is updated, the table isn't displayed correctly. Sometimes even-numbered row text is not displayed, sometimes the row heights are screwed up, sometimes I see nothing. If I do a column sort on the table, or if I reposition the application window using the Windows key + arrow method, then it's displayed correctly.

    An example, to illustrate; this is how it should look:

    This is good

    And here's how it looks when the model gets updated:

    This is not good

    The TableView itself is instantiated within an Item, which is in turn instantiated within an ApplicationWindow.

    Any ideas on how to get the table displaying correctly?

    Cheers,

    Garry

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Monomix
      wrote on 24 Mar 2015, 16:38 last edited by Monomix
      #2

      So, here's a video illustrating this issue properly:

      http://www.enclustra.com/assets/temp/TableView.mp4

      Can anyone suggest where I should look to dig for more info on this in the Qt Quick source code? To me it smells like a bug; the QAbstractTableModel is set via context property, and in QML the TableView is simple:

              TableView {
                  id: propertiesTable
                  Layout.fillWidth: true
                  Layout.fillHeight: true
                  enabled: rowCount > 0
                  frameVisible: true
                  headerVisible: true
                  sortIndicatorVisible: true
                  alternatingRowColors: true
                  model: standardConfigurationPropertiesTableModel
      
                  onSortIndicatorColumnChanged: {
                      model.sort(sortIndicatorColumn, sortIndicatorOrder)
                  }
                  onSortIndicatorOrderChanged: {
                      model.sort(sortIndicatorColumn, sortIndicatorOrder)
                  }
      
                  TableViewColumn {
                      id: nameColumn
                      role: "standardConfigPropertyDescription"
                      title: qsTr("Property")
                      width: propertiesTable.width / 2 - 1
                      resizable: false
                  }
                  TableViewColumn {
                      id: valueColumn
                      role: "standardConfigPropertyValue"
                      title: qsTr("Value")
                      width: propertiesTable.width / 2 - 1
                      resizable: false
                  }
              }
      
      1 Reply Last reply
      0
      • M Offline
        M Offline
        Monomix
        wrote on 7 Apr 2015, 09:16 last edited by Monomix 4 Jul 2015, 09:16
        #3

        Turns out this was a threading issue. The object that contained my QAbstractTableModel-derived models had been moved to a worker thread, which doesn't work well with the model/view architecture - both the GUI thread and the worker thread were sending signals to the models, which meant that insert row and remove row operations were overlapping each other, hence the odd behaviour.

        The main take-out is: when using the model/view approach, the models must have the same thread affinity as the views (i.e. keep the models on the main application thread); don't move them to worker threads unless you want to get jiggy with serialising access.

        A thread that did help: http://stackoverflow.com/questions/9485339/design-pattern-qt-model-view-and-multiple-threads

        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