Nominate our 2022 Qt Champions!

Table cross

  • Hi guys,

    I'll provide you a picture to illustrate my question.

    0_1528725657570_Sans titre.png

    So when I say "table" I mean table from a database.

    The question is : Is it possible to get a view like that ?
    Of course, I know that getting assets classified by profils is tricky, so if this isn't possible, I can change cell colors instead of having profils names.

    The goal here, is populate the first row and column from different tables of a database and let the user check if there is a link between an asset and a process.
    Of course, that would be great to populate a third table with the cross information.

    • create a QStandardItemModel
    • select the "process" table, iterate over it and call QStandardItemModel::insertColumn + QStandardItemModel::setHeaderData to insert a column and set its value
    • select from the asset table sorting by Profil, iterate over the results
      • check if profil changes from one to the next, if it does use QStandardItemModel::insertRow + QStandardItemModel::setHeaderData + QStandardItemModel::setData(,,Qt::BackgroundRole) + QStandardItemModel::item()->setFlag to add a row that can't be interacted with
      • if it doesn't change use QStandardItemModel::insertRow + QStandardItemModel::setHeaderData to add an asset row and use QStandardItemModel::item()->setFlag + QStandardItemModel::setData(,Qt::Unchecked,Qt::CheckStateRole) to allow checking/unchecking
    • iterate over the table and use QStandardItemModel::data(,Qt::CheckStateRole).toInt() to check if the cell is checked or not and save that information whenever you want

  • @VRonin Thank you, that's what I was looking for !

Log in to reply