[Qt-interest] QListView ModelColumn
Andre Somers
andre at familiesomers.nl
Mon Dec 7 09:42:24 CET 2009
Philipp Schmidt wrote:
> Hi,
>
> as QTreeView is not exactly what i need i just skimmed through the docs and
> overrode the data() method with the following code:
>
> QVariant Class::data ( const QModelIndex& idx, int role ) const {
> if (!idx.isValid()) {
> return QVariant();
> } if (idx.column() == 0 && role == Qt::DisplayRole) {
> return record(idx.row()).value("lastname").toString() + ", " +
> record(idx.row()).value("firstname").toString();
> }
> return QSqlTableModel::data ( idx, role );
> }
>
> That works like a charm and wasn't really that hard to do :D. Thanks for your
> help anyway.
>
> Philipp Schmidt
>
>
If you need multiple columns, why not use the view that was made for
that: QTableView? I know it looks like an ugly spreadsheet in the
default setup, but that's easy enough to change.
André
More information about the Qt-interest-old
mailing list