Adding button to QTableview

前端 未结 6 1674
遥遥无期
遥遥无期 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:45

    When the view wants to draw a cell it calls the delegate’s paint() function with some information about how, what, and where to draw the contents of the cell. The default delegate just draws the Qt::DisplayRole text and selectionState.

    If you replace the delegate then you completely replace the default behaviour: you can draw whatever you like. If you want the text then you need to arrange to draw it. You can do it yourself or, using standard C++ mechanisms, you can call the default drawing code first then draw over the top. It works after adding QItemDelegate::paint(painter, option, index); at the beginning of my paint() method .

提交回复
热议问题