model/view
-
@user4592357
For tables:QAbstractTableModel
For trees:QAbstractItemModelBut i suggest you first implement a table model, before jumping onto the tree model implementation, for the sake of simplicity.
About how many cells in the end are we talking actually?
If we are not talking about hundreds to thousands you can also use QStandartItems (with QTreeWidget/QTableWidget) as @VRonin suggested.@raven-worx
the cells are a lot actuallyand about your code snippet, what if the row/column values aren't known beforehand?
-
@user4592357
For tables:QAbstractTableModel
For trees:QAbstractItemModelBut i suggest you first implement a table model, before jumping onto the tree model implementation, for the sake of simplicity.
About how many cells in the end are we talking actually?
If we are not talking about hundreds to thousands you can also use QStandartItems (with QTreeWidget/QTableWidget) as @VRonin suggested.@raven-worx said in model/view:
If we are not talking about hundreds to thousands you can also use QStandartItems
I actually use tens of thousands tree elements with
QStandartItemModeland works for me -
@raven-worx said in model/view:
If we are not talking about hundreds to thousands you can also use QStandartItems
I actually use tens of thousands tree elements with
QStandartItemModeland works for me@VRonin said in model/view:
I actually use tens of thousands tree elements with QStandartItemModel and works for me
i never said it's not working, but it's a waste of memory.
And thus discouraged to do so (from my side). -
@VRonin said in model/view:
I actually use tens of thousands tree elements with QStandartItemModel and works for me
i never said it's not working, but it's a waste of memory.
And thus discouraged to do so (from my side).@raven-worx
about your code snippet, what if the row/column values aren't known beforehand? -
@raven-worx
about your code snippet, what if the row/column values aren't known beforehand?@user4592357
then reusing the QHash structure is not ideal, you could use your matrix approach then -
@user4592357
then reusing the QHash structure is not ideal, you could use your matrix approach then@raven-worx
can't i useQTableWidgetandQTreeWidgetsince my models aren't reused? -
@raven-worx
can't i useQTableWidgetandQTreeWidgetsince my models aren't reused?@user4592357 That's basically the same as using
QStandartItemModelthat we suggested at the beginning -
@user4592357 That's basically the same as using
QStandartItemModelthat we suggested at the beginning@VRonin
how is it the same?should i use the same
QStandartItemModelfor both views? -
I mean
QStandartItemModel+QTreeView=QTreeWidgetandQStandartItemModel+QTableView=QTableWidget@VRonin @raven-worx
i have another question.so my table widget consists of 2 widgets:
QTableViewand aQTextEditunder it to display info about a particular cell.the data container i use to set model data consists of two maps:
- data storage for table view
- data storage for text edit
how should i handle this in
data()? -
should i user two different containers???