Originally Posted by
ada10
If I had say 20 items ( QStandardItems ) to the tableview, it just puts it into one vertical list ...
why has the QGridView class been removed ?
You add items to a model, not a view (QTableWidget just hides the model from you). If you add all the items in column 0 then that is what will be displayed by any view you attach to that model. Take a look at QStandardItemModel::setItem() for a way to set a cell other than column 0, or QStandardItemModel::insertRow() or insertColumn() (the ones that take a list of items) for ways to add whole rows/columns.
I plan to add custom items to the table view using custom model class later on ... but it should work with any type of items ... row/column hiding does not work ...
Yes it does.
#include <QtGui>
int main(int argc, char *argv[])
{
for (int row = 0; row < 8; ++row) {
for (int column = 0; column < 8; ++column) {
model.setItem(row, column, item);
}
}
v.setModel(&model);
v.setRowHidden(3, true);
v.setColumnHidden(3, true);
v.show();
return app.exec();
}
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QStandardItemModel model(8, 8);
for (int row = 0; row < 8; ++row) {
for (int column = 0; column < 8; ++column) {
QStandardItem *item = new QStandardItem(QString("%0, %1").arg(row).arg(column));
model.setItem(row, column, item);
}
}
QTableView v;
v.setModel(&model);
v.setRowHidden(3, true);
v.setColumnHidden(3, true);
v.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks