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. QML Tableview select row where data in column matches
Qt 6.11 is out! See what's new in the release blog

QML Tableview select row where data in column matches

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 1.4k 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.
  • E Offline
    E Offline
    eagain
    wrote on last edited by eagain
    #1

    Hello,

    we are using a QML tableview and want to select a certain row from c++. The Tableview is using an AbstractTableModel and a SortFilterProxyModel. I've created a QML function in the root object to do so. The function takes a value and should make the tableview select a row where the value matches the data in a predetermined column.

    So i need something like in this (pseudo-)code snippet

        function setCurrentRow(value_in_col_0)
        {            
            var SourceIndex = tableModel.???
            var SortModelIndex = proxyModel.mapFromSource(SourceIndex)            
            MyTable.selection.clear()
            MyTable.selection.select(SortModelIndex.row)
            MyTable.currentRow = SortModelIndex.row
            console.log("in setCurrentRow with index: ", SortModelIndex.row)
        }
    

    My question is what is the best way to select the ModelIndex in the original, unsorted AbstractTableModel? Is it viable to do so in QML or should I rather do that in c++?

    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