To do this, you will have to implement your own delegate.
In Qt, in addition to data, models, and views, you have your delegates. They provide input capabilities, and they are also responsible for providing โspecialโ elements in the presentation, which is what you need.
Qt doc has good coverage for those (keywords: Model/View programming ), and you can also find some examples here and here .
Also (a little off topic, but I think I should point this out), if you use a regular QTableWidget , you can insert anything into any cell using the setCellWidget() function.
UPD
here is a slightly modified example from Qt docs (I suck with a model / view in Qt, so don't beat me for this code). He will draw a button in each cell on the right and catch the click events in the cells to check if there was a click on the "button" and react accordingly.
This is probably not the best way to do this, but as I mentioned, I'm not too good with Qt models and views.
To do everything right and allow correct editing, you also need to implement the createEditor() , setEditorData() and setModelData() .
To draw your things in a specific cell instead of all the cells, just add a condition to the paint() function (note that it takes the model index as an argument, so you can always find out which cell you draw in and draw accordingly).
delegate.h:
class MyDelegate : public QItemDelegate { Q_OBJECT public: MyDelegate(QObject *parent = 0); void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index); };
delegate.cpp:
#include <QtGui>
main.cpp
#include "delegate.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); QStandardItemModel model(4, 2); QTableView tableView; tableView.setModel(&model); MyDelegate delegate; tableView.setItemDelegate(&delegate); tableView.horizontalHeader()->setStretchLastSection(true); tableView.show(); return app.exec(); }
The result will look like this:
