PDA

View Full Version : creating new model/view



swiety
27th October 2007, 22:54
I would like to display data like this:

col_1 col_2 col_3
row_1 |...........|...........|.............|
row_2 |.....................................|
row_3 |...........|...........|.............|
row_4 |...........|...........|.............|
row_5 |.....................................|
....

With model/view should i use? Is this possible (in general) to display data like this?

jpn
27th October 2007, 23:21
You can use QTableView and its QTableView::setSpan(). The model is choice of yours.. ;)

A quick preview of what QTableView is capable of:


#include <QtGui>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTableWidget table(5, 3);
table.setSpan(1, 0, 1, 3);
table.setSpan(4, 0, 1, 3);
table.show();
return app.exec();
}

(QTableWidget is a QTableView with built-in model)

Edit: PS. If you have an existing data structure, I suggest wrapping it to a QAbstractTableModel. Otherwise you may use QStandardItemModel or maybe even QTableWidget as well, depending on your needs.