tonnot
21st September 2010, 19:27
This is the original code :
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QStandardItemModel model(4, 2);
QTableView tableView;
tableView.setModel(&model);
tableView.horizontalHeader()->setStretchLastSection(true);
for (int row = 0; row < 4; ++row) {
for (int column = 0; column < 2; ++column) {
QModelIndex index = model.index(row, column, QModelIndex());
model.setData(index, QVariant((row+1) * (column+1)));
}
}
tableView.setWindowTitle(QObject::tr("Spin Box Delegate"));
tableView.show();
return app.exec();
}
And this is my code (I use a TableView out on a window using Designer)
QStandardItemModel modelo(4, 2);
ui->tableView->setModel(&modelo);
ui->tableView->horizontalHeader()->setStretchLastSection(true);
for (int row = 0; row < 4; ++row) {
for (int column = 0; column < 2; ++column) {
QModelIndex index = modelo.index(row, column, QModelIndex());
modelo.setData(index, QVariant((row+1) * (column+1)));
}
}
(I only delete the 'delegate' code, in order to simply test how it works)
Ok, in my case I see the table but i dont see the cells neither its content.
What happens ?
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QStandardItemModel model(4, 2);
QTableView tableView;
tableView.setModel(&model);
tableView.horizontalHeader()->setStretchLastSection(true);
for (int row = 0; row < 4; ++row) {
for (int column = 0; column < 2; ++column) {
QModelIndex index = model.index(row, column, QModelIndex());
model.setData(index, QVariant((row+1) * (column+1)));
}
}
tableView.setWindowTitle(QObject::tr("Spin Box Delegate"));
tableView.show();
return app.exec();
}
And this is my code (I use a TableView out on a window using Designer)
QStandardItemModel modelo(4, 2);
ui->tableView->setModel(&modelo);
ui->tableView->horizontalHeader()->setStretchLastSection(true);
for (int row = 0; row < 4; ++row) {
for (int column = 0; column < 2; ++column) {
QModelIndex index = modelo.index(row, column, QModelIndex());
modelo.setData(index, QVariant((row+1) * (column+1)));
}
}
(I only delete the 'delegate' code, in order to simply test how it works)
Ok, in my case I see the table but i dont see the cells neither its content.
What happens ?