Skip to content
  • 0 Votes
    8 Posts
    722 Views
    F

    @JonB My EDIT revision now prints the column heading I wanted. Hopefully I only need to run that header saveState function just before program exit, and restoreState just before displaying my table on the next run. If that does what I want, I won't need to directly deal with "visual indexes" at all at this stage in my ongoing "personal movie database" project.
    Once I can persistently re-sequence columns, I hope to add several more columns, with the less interesting ones dragged to the right of the row out of the way. I already remember user-revised column widths, so I can make those rightmost columns as narrow as possible, but I fully expect to progress to optionally hiding temporarily unwanted columns.
    Anyway, I'm getting older and slower, so it'll probably take me a few days just to implement "moved column memory" in my app. But eventually I want several members of a "cinema club" each having read/write access to their own database (on DropBox, GoogleDrive, whatever), and read-only access to the other members' databases (to retrieve "rating" and "date seen" values by user).

  • 0 Votes
    4 Posts
    483 Views
    F

    An update on this from my side:

    My initial approach wasn't flawless, as @VRonin pointed out, because QAbstractItemModel::columnCount didn't return the appropriate values. I've fixed this, by not immediately passing the new count after inserting the elements to a list, of which the size was used, but instead have the model save exactly how many categories it currently accounts for, so the connection looks like this:

    connect(item_registry.get(), &item_registry::category_added, [this](int position, QSharedPointer<category>) { beginInsertColumns(QModelIndex{}, position, position); _current_category_count++; endInsertColumns(); });

    and likewise columnCount:

    int item_model::columnCount(QModelIndex const&) const { if(!_register) { qCritical() << "Item-model didn't have a register"; return 0; } return 1 /* name */ + _current_category_count; }
  • 0 Votes
    2 Posts
    3k Views
    R

    Finally I solved it!!!

    function fillRow() { table.model = undefined // <--- 1 if (!tableModel.count) { tableModel.append({"C0":50}) } else { tableModel.setProperty(0,"C"+(table.columnCount-1),50+table.columnCount-1) } table.model = tableModel //<--- 2 var x = tableModel.get(0) console.log("Num. Columns",table.columnCount,"row object",JSON.stringify(x)) }

    When I fill the columns, I set TableView.model to undefined(1), then fill the rows, and after I set TableView.model to ListModel again(2)