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. How to know that QTableView is in editing state

How to know that QTableView is in editing state

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 4 Posters 1.1k 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.
  • tovaxT Offline
    tovaxT Offline
    tovax
    wrote on last edited by
    #1

    Hi, all
    The different columns of QTableView have set delegates, the table model is QSqlTableModel, and everything is working normally. According to the needs of the project, when QTableView is idle, its background color will change randomly. When double-clicking any cell to enter the editing state, its background color will stop refreshing.
    I tried the “hasFocus” property, “entered” signal, and “viewportentered” signal, but the Editing State cannot be obtained correctly.
    How do I know if a cell in QTableView is being edited, please?
    Best regards!

    VRoninV 1 Reply Last reply
    0
    • tovaxT tovax

      Hi, all
      The different columns of QTableView have set delegates, the table model is QSqlTableModel, and everything is working normally. According to the needs of the project, when QTableView is idle, its background color will change randomly. When double-clicking any cell to enter the editing state, its background color will stop refreshing.
      I tried the “hasFocus” property, “entered” signal, and “viewportentered” signal, but the Editing State cannot be obtained correctly.
      How do I know if a cell in QTableView is being edited, please?
      Best regards!

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      @tovax said in How to know that QTableView is in editing state:

      How do I know if a cell in QTableView is being edited, please?

      In the delegate emit a signal just before returning from setEditorData

      "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

      tovaxT 1 Reply Last reply
      4
      • VRoninV VRonin

        @tovax said in How to know that QTableView is in editing state:

        How do I know if a cell in QTableView is being edited, please?

        In the delegate emit a signal just before returning from setEditorData

        tovaxT Offline
        tovaxT Offline
        tovax
        wrote on last edited by
        #3

        @VRonin Hi, thank you very much for your reply, it solved my problem perfectly!
        Best regards!

        1 Reply Last reply
        0
        • tovaxT Offline
          tovaxT Offline
          tovax
          wrote on last edited by
          #4

          If no delegation is used, how can this problem be solved?

          VRoninV 1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @tovax said in How to know that QTableView is in editing state:

            If no delegation is used, how can this problem be solved?

            Overwrite QTableView::edit()

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            JonBJ tovaxT 2 Replies Last reply
            3
            • Christian EhrlicherC Christian Ehrlicher

              @tovax said in How to know that QTableView is in editing state:

              If no delegation is used, how can this problem be solved?

              Overwrite QTableView::edit()

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

              @Christian-Ehrlicher said in How to know that QTableView is in editing state:

              Overwrite QTableView::edit()

              @tovax
              Plus see https://doc.qt.io/qt-5/qabstractitemview.html#closeEditor and https://doc.qt.io/qt-5/qabstractitemview.html#state.

              1 Reply Last reply
              1
              • Christian EhrlicherC Christian Ehrlicher

                @tovax said in How to know that QTableView is in editing state:

                If no delegation is used, how can this problem be solved?

                Overwrite QTableView::edit()

                tovaxT Offline
                tovaxT Offline
                tovax
                wrote on last edited by
                #7

                @Christian-Ehrlicher
                @JonB
                Thank you very much.

                1 Reply Last reply
                0
                • tovaxT tovax

                  If no delegation is used, how can this problem be solved?

                  VRoninV Offline
                  VRoninV Offline
                  VRonin
                  wrote on last edited by
                  #8

                  @tovax said in How to know that QTableView is in editing state:

                  If no delegation is used,

                  A delegate is always used. The default one is QStyledItemDelegate so you can just subclass it and only add the signal

                  "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
                  2

                  • Login

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