简体   繁体   中英

Make all items in a QTreeWidget editable

Is it possible to make all items in a QTreeWidget editable on user double-click?

在此处输入图片说明

I have already set the only editing-related property I found - editTriggers - to DoubleClicked|EditKeyPressed , but the items are still not editable.

I found the answer from https://forum.qt.io/topic/20980/solved-can-qtreewidget-really-be-edited . Apparently each item needs to have its editable flag set.

To do it, I iterated over all of the items and set the editable flag:

QTreeWidgetItemIterator it(ui->treeWidget);
while (*it) {
    (*it)->setFlags((*it)->flags() | Qt::ItemIsEditable);
    ++it;
}

It works after that!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM