Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    slot signal qtablewidget clicked
    3
    5
    4833
    Loading More Posts
    • 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.
    • cxam
      cxam last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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

        cxam 1 Reply Last reply Reply Quote 0
        • cxam
          cxam @SGaist last edited by

          @SGaist Hi can you provide me an example please?

          Stay Hungry, Stay Foolish

          mrjj 1 Reply Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion @cxam last edited by 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;
            }
            
            cxam 1 Reply Last reply Reply Quote 3
            • cxam
              cxam @mrjj last edited by

              @mrjj Thanks :)

              Stay Hungry, Stay Foolish

              1 Reply Last reply Reply Quote 0
              • First post
                Last post