Qt – QTableView – Clickable button in table row

Qt – QTableView – Clickable button in table row

Asked on January 10, 2019 in Qt.
Add Comment


  • 2 Answer(s)

    Clickable button in table row:

    By  underlining the link  the clickable text  are captured  the cell click  the cellClicked row, col signal and check that col == editColumn. Then row  can compare the    item by editing.

    Data Name | Value 1 | Value 2 | Edit

     

    connect (tableWidget, SIGNAL(cellClicked(int,int)), this, SLOT(editSlot(int, int)));
     
    ...
     
    void ClassName::editSlot(int row, int col){
        if (col == 3) {
          doWork(row);
        }
    }
    

     

    Answered on January 10, 2019.
    Add Comment

    The alternative answer is:

    By using the  setIndexWidget    and  for more information  click the Qt documentation

    And then  push a button in the first column of the second row  unproved code.

    tableView->setIndexWidget(tableView->model()->index(2, 1), new QPushButton);
    
    
    Answered on January 10, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.