Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Set Flags with QSqlModel
Forum Updated to NodeBB v4.3 + New Features

Set Flags with QSqlModel

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 855 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ankit thakarA Offline
    ankit thakarA Offline
    ankit thakar
    wrote on last edited by
    #1

    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 ???

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Subclass QSqlTableModel and reimplement the flags method.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        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)

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved