0

I would like add QPushButtons to my QTableView. How can this be done with Qt? Is it possible to specify which column holds the button If I use QItemDelegate?

László Papp
  • 51,870
  • 39
  • 111
  • 135
user476566
  • 1,319
  • 3
  • 26
  • 42

1 Answers1

2

You've got to create your own PushButtonDelegate by subclassing QItemDelegate.

QAbstractItemView::setItemDelegateForColumn(int column, QAbstractItemDelegate * delegate) will set your delegate for the specified column of a view.

The implementation of the delegate depends on it's desired behavior. E.g. you can implement only createEditor(), setEditorData() and setModelData() to get the button to appear when the user starts editing a cell, or you can change the cell look completely by reimplementing the delegate's paint() method. For more information see this. Also take a look at the Qt delegate examples.

VVV
  • 499
  • 4
  • 12