croppio.com
croppio.com

Reputation: 1883

Star Delegate in QTableWidget

I have copied stardelegate, stareditor and starrating source and header files from example http://doc.qt.io/qt-5/qtwidgets-itemviews-stardelegate-example.html, and i try to implement star rating functionality into a tree widget instead of a table widget like from example. The stars are showing, the problem is that are not editable like in the aforementioned example, in fact the whole row. My code causing this:

ui->tree->setItemDelegate(new StarDelegate);
ui->tree->setItemDelegateForColumn(2, new StarDelegate);
ui->tree->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked);
ui->tree->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tree->setColumnCount(3);
ui->tree->setHeaderLabels(QStringList() << "Name" << "Date" << "Rating");

Please tell me what i am doing wrong, thank you.

Upvotes: 0

Views: 691

Answers (1)

alexisdm
alexisdm

Reputation: 29886

QTableWidget items are editable by default, QTreeWidget items are not.

You will have to add the flag Qt::ItemIsEditable to the existing flags for all the items in the rating columns.

Upvotes: 3

Related Questions