QSortFilterProxyModel subclass for text alignment -and readonly columns
Jump to navigation
Jump to search
QSortFilterProxyModel subclass for text alignment and readonly columns
When using the model/view framework it is not possible to:
- enable or disable different columns of the table
- set text alignment for different columns
For this I created the following code after a thread I posted link [developer.qt.nokia.com]. Here it is the code:
Header
Source file
Example
Note that you do not need to connect the proxy with the source model before starting to configure it. It is independent. You can assign infinite (limited by hardware) column properties and apply them to any model (to be tested). You can find all the existant Qt::Alignment and Qt::ItemFlags in Qt documentation.
In my program, I am using a QSqlRelationalTableModel and when this proxymodel was applied the combo boxes were replaced with text edit boxes on the QTableView… the solution for this you can find it here [developer.qt.nokia.com].