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. TableModel question about Qt::CheckStateRole

TableModel question about Qt::CheckStateRole

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 255 Views
  • 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by Perdrix
    #1

    The data for my table is held in a vector of class instances.

    If the data in a class instance that represents a row/column intersection is changed, I know I need to tell the TableModel that it has been changed.

    My data mf() for the model has:

    if (role == Qt::CheckStateRole)
    {
          if (0 == index.column())
              return file.m_bChecked;   // can be QT::Checked or Qt::Unchecked
          else return QVariant();
    }
    

    What should I do if I modify the m_bChecked variable for a row - do I tell the model that column 0 of the row has changed or ???

    JonBJ 1 Reply Last reply
    0
    • PerdrixP Perdrix

      The data for my table is held in a vector of class instances.

      If the data in a class instance that represents a row/column intersection is changed, I know I need to tell the TableModel that it has been changed.

      My data mf() for the model has:

      if (role == Qt::CheckStateRole)
      {
            if (0 == index.column())
                return file.m_bChecked;   // can be QT::Checked or Qt::Unchecked
            else return QVariant();
      }
      

      What should I do if I modify the m_bChecked variable for a row - do I tell the model that column 0 of the row has changed or ???

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Perdrix
      In your code you only use m_bChecked for column #0, so if you alter that you need to emit dataChanged() for column #0 with role Qt::CheckStateRole. Is that what you were asking?

      1 Reply Last reply
      1
      • PerdrixP Offline
        PerdrixP Offline
        Perdrix
        wrote on last edited by
        #3

        Yes I think it was

        D.

        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