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
Forum Updated to NodeBB v4.3 + New Features

QTableView how to detect user click on cell

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 5 Posters 3.4k 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.
  • P Offline
    P Offline
    Publicnamer
    wrote on 10 Oct 2021, 06:19 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
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 10 Oct 2021, 06:42 last edited by mrjj 10 Oct 2021, 06:51
      #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 10 Oct 2021, 17:43 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.

        E 1 Reply Last reply 10 Oct 2021, 17:53
        0
        • P Publicnamer
          10 Oct 2021, 17:43

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

          E Offline
          E Offline
          eyllanesc
          wrote on 10 Oct 2021, 17:53 last edited by eyllanesc 10 Oct 2021, 17:54
          #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 10 Oct 2021, 18:49
          3
          • E eyllanesc
            10 Oct 2021, 17:53

            @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 10 Oct 2021, 18:49 last edited by Publicnamer 10 Oct 2021, 18:49
            #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

            E 1 Reply Last reply 10 Oct 2021, 21:03
            0
            • C Offline
              C Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 10 Oct 2021, 19:07 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
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 10 Oct 2021, 19:37 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
                  10 Oct 2021, 18:49

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

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

                  E Offline
                  E Offline
                  eyllanesc
                  wrote on 10 Oct 2021, 21:03 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

                  1/8

                  10 Oct 2021, 06:19

                  • Login

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