1

为什么我的 QTreeWidgetItem 不可编辑?我用这段代码来实现一个:

ui->treeWidget->expandAll();
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(0, "Add details about your Bug");
bug->addChild(item);
ui->treeWidget->editItem(item, 0);
4

1 回答 1

1

您忘记在 QTreeWidgetItem 中将 editable 设置为 true (默认为 false):

ui->treeWidget->expandAll();
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(0, "Add details about your Bug");
item->setFlags(item->flags() | Qt::ItemIsEditable);
bug->addChild(item);
ui->treeWidget->editItem(item, 0);
于 2012-09-22T19:50:27.553 回答