Adding button to QTableview

前端 未结 6 1638
遥遥无期
遥遥无期 2020-12-14 10:57

I have created one table by using QTableview and QAbstractTableModel . In one of the cells, I want to add one help button in the r

6条回答
  •  离开以前
    2020-12-14 11:46

    setIndexWidget worked for me. Example:

    QPushButton* helpButton = new QPushButton("Help");
    
    tableView->setIndexWidget(model->index(position,COLUMN_NUMBER), helpButton);
    

    If you just want to add a button and do something on click of it, adding a button using setIndexWidget() works fine. I believe we don't need the cumbersome paint method or implementing delegates.

提交回复
热议问题