QSortFilterProxyModel subclass for text alignment -and readonly columns

From Qt Wiki
Revision as of 16:38, 14 January 2015 by Maintenance script (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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:

  1. enable or disable different columns of the table
  2. 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].

Categories: