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. QTableview set column data unchanged
Qt 6.11 is out! See what's new in the release blog

QTableview set column data unchanged

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 592 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.
  • N Offline
    N Offline
    n-2204
    wrote on last edited by
    #1

    Hi,

    I am using Qtableview (QAbstractItemModel)

    I have two Qtableview tables ,, so in table2 I want one column(column name =Column_A) as :
    A. if there is not data in Column_A in any row that type user can enter data
    B. if user entered data in Column_A once then he should not be allow to change
    the data.(like if user type also then it should reset to prev data)
    C. if data in Column_A is coming from table1 column then it should show same
    data , if user change data in table1 column then also it should display same and not allow to chnge data in table2 Column_A

    How to do this ?? basically how should I apply CONDITION B ?

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

      Hi,

      You can make the cell uneditable after it has been edit.

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

      N 1 Reply Last reply
      3
      • SGaistS SGaist

        Hi,

        You can make the cell uneditable after it has been edit.

        N Offline
        N Offline
        n-2204
        wrote on last edited by
        #3

        @SGaist ok. what i can use to make only cell uneditable] if there is data bcz I'm using Qtableview ( QAbstractitemmodel) ??

        JonBJ 1 Reply Last reply
        0
        • N n-2204

          @SGaist ok. what i can use to make only cell uneditable] if there is data bcz I'm using Qtableview ( QAbstractitemmodel) ??

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

          @n-2204
          Qt::ItemFlags QAbstractItemModel::flags(const QModelIndex &index) const. Among the flags Qt::ItemFlags is Qt::ItemIsEditable, which you should mask out on indexes once they have been edited. You will obviously need to store somewhere which indexes have been edited.

          1 Reply Last reply
          4

          • Login

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