[Interest] QTableView column format

André Somers andre at familiesomers.nl
Wed Jan 22 10:24:17 CET 2014


Muhammad Bashir Al-Noimi schreef op 21-1-2014 18:22:
>        Howdy,
>
> I'm using QTableView in very basic mode to view a QSqlTableModel but one
> of numeric column shows the numbers using 'e' factor while they should
> be in digits only '1000000'
>
> How can I change the format of specific column without subclassing
> QTableView?
>
> Can I change the format from QSqlTableModel or it should only modify
> from QTableView?
>
Both options are possible. You can either change it from the model side, 
or at the view site using a delegate. Finally, you can use a proxy model 
to change the representation.

If you want to modify it at the 'view' end, you should use a 
QStyledItemDelegate subclass and install that on the view, or on a 
specific column of the view. If you go the model way, you should modify 
the data() method for the given column for the Qt::DisplayRole, and 
return a string there with represents the number in the right format.

André



More information about the Interest mailing list