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 get a slot when a row of a QTableWidget is clicked ?
QtWS25 Last Chance

How to get a slot when a row of a QTableWidget is clicked ?

Scheduled Pinned Locked Moved Solved General and Desktop
slotsignalqtablewidgetclicked
5 Posts 3 Posters 5.5k 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.
  • cxamC Offline
    cxamC Offline
    cxam
    wrote on last edited by
    #1

    Hi!
    I need a way in which where the user clicks a whole row (not only a cell) I can execute a function.
    Thanks in advance.

    Stay Hungry, Stay Foolish

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

      Hi,

      You should check the QHeaderView::sectionClicked signal.

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

      cxamC 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        You should check the QHeaderView::sectionClicked signal.

        cxamC Offline
        cxamC Offline
        cxam
        wrote on last edited by
        #3

        @SGaist Hi can you provide me an example please?

        Stay Hungry, Stay Foolish

        mrjjM 1 Reply Last reply
        0
        • cxamC cxam

          @SGaist Hi can you provide me an example please?

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @cxam
          hi
          in mainwin.h

          class MainWindow : public QMainWindow
          {...
          public slots:
           void sectionClicked(int);
          ...
          define slot
          hook it up ( in mainwin constructor)
          connect( ui->tableWidget->verticalHeader(), &QHeaderView::sectionClicked , this, &MainWindow::sectionClicked);
          - in .cpp
          void MainWindow::sectionClicked(int index) {
          qDebug() << "row sel:" << index;
          }
          
          cxamC 1 Reply Last reply
          3
          • mrjjM mrjj

            @cxam
            hi
            in mainwin.h

            class MainWindow : public QMainWindow
            {...
            public slots:
             void sectionClicked(int);
            ...
            define slot
            hook it up ( in mainwin constructor)
            connect( ui->tableWidget->verticalHeader(), &QHeaderView::sectionClicked , this, &MainWindow::sectionClicked);
            - in .cpp
            void MainWindow::sectionClicked(int index) {
            qDebug() << "row sel:" << index;
            }
            
            cxamC Offline
            cxamC Offline
            cxam
            wrote on last edited by
            #5

            @mrjj Thanks :)

            Stay Hungry, Stay Foolish

            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