Set Flags with QSqlModel



  • Hello,

    I have used Table View and QSqlModel in my code.
    Now In my table view I want to enable or disable some cells on basis of some check.
    I found that with QTableModel we can easily set Flags and on basis of that it will enable or disable particular cells.

    But how to do this same with QSqlModel ???


  • Lifetime Qt Champion

    Hi,

    Subclass QSqlTableModel and reimplement the flags method.



  • Or just use a proxy on top of the model, here is an example of proxy that lets you set flag for columns, rows or individual cells.

    Notes:

    • I used QSortFilterProxyModel as base as I use the base class capabilities but QIdentityProxyModel works as well as base
    • My implementation works only with flat models (no trees structure)

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.