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 how to detect user click on cell

QTableView how to detect user click on cell

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 5 Posters 3.4k 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.
  • P Offline
    P Offline
    Publicnamer
    wrote on last edited by
    #1

    Looking at the list of signals for QTableView and QAbstractItemModel, I don't see any that would let me detect when the user has clicked on a cell in the table?
    Is it possible to detect that?

    https://doc.qt.io/qt-5/qabstractitemmodel.html#dataChanged

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

      Hi
      There is https://doc.qt.io/qt-5.15/qtableview.html#currentChanged
      That tells when the current index is changed, aka user click on some cell.
      or
      https://doc.qt.io/qt-5.15/qabstractitemview.html#clicked

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Publicnamer
        wrote on last edited by
        #3

        Oh, I see now that I should really be using QTableWidget instead, which has useful signals, whereas QTableView has no signals.

        eyllanescE 1 Reply Last reply
        0
        • P Publicnamer

          Oh, I see now that I should really be using QTableWidget instead, which has useful signals, whereas QTableView has no signals.

          eyllanescE Offline
          eyllanescE Offline
          eyllanesc
          wrote on last edited by eyllanesc
          #4

          @Publicnamer QTableWidget is a QTableView so all QTableView methods and signals are available in QTableWidget, so inheritance works.

          Although QTableWidget also has new signals:

          • https://doc.qt.io/qt-5.15/qtablewidget.html#cellClicked
          • https://doc.qt.io/qt-5.15/qtablewidget.html#itemClicked
          • https://doc.qt.io/qt-5.15/qtablewidget.html#currentItemChanged
          • https://doc.qt.io/qt-5.15/qtablewidget.html#currentCellChanged

          Note: Both have useful signals for your requirement.

          If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

          P 1 Reply Last reply
          3
          • eyllanescE eyllanesc

            @Publicnamer QTableWidget is a QTableView so all QTableView methods and signals are available in QTableWidget, so inheritance works.

            Although QTableWidget also has new signals:

            • https://doc.qt.io/qt-5.15/qtablewidget.html#cellClicked
            • https://doc.qt.io/qt-5.15/qtablewidget.html#itemClicked
            • https://doc.qt.io/qt-5.15/qtablewidget.html#currentItemChanged
            • https://doc.qt.io/qt-5.15/qtablewidget.html#currentCellChanged

            Note: Both have useful signals for your requirement.

            P Offline
            P Offline
            Publicnamer
            wrote on last edited by Publicnamer
            #5

            @eyllanesc If you look at the documentation for QTableView, it does not list any signals:

            https://doc.qt.io/qt-5.15/qtableview.html

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

              @Publicnamer said in QTableView how to detect user click on cell:

              it does not list any signals:

              Because they're all in the base class - QAbstractItemView

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

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

                Hi,

                Depending on what you want to do, the view's selection model might also be of interest.

                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
                • P Publicnamer

                  @eyllanesc If you look at the documentation for QTableView, it does not list any signals:

                  https://doc.qt.io/qt-5.15/qtableview.html

                  eyllanescE Offline
                  eyllanescE Offline
                  eyllanesc
                  wrote on last edited by
                  #8

                  @Publicnamer It is recommended that you check https://doc.qt.io/qt-5.15/qtablewidget-members.html where all the methods and signals of QTableWidget are (together with the base classes)

                  If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

                  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