开发者

QTreeWidget : disable a line but not the subtree

I use a QTreeWidget that shows a file listing so that a user can copy files to a directory. I want to disallow the user to copy the files to the same directory. Thus, I want to disable just one line in my QTreeWidget so that it is not selectable. I tried to use the setDisable(bool) method of the QTreeWidgetItem object but the problem is it disables the whole subtree.

How to get just one line dis开发者_运维百科abled in a QTreeWidget ?


I would try to disable the Qt::ItemIsDropEnabled flag with QTreeWidgetItem::setFlags, ie.e. setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled)

I did not test this.


If you want to disallow copying files into a directory, make directory read-only.

chmod(dir, 0555) will do directory - dir readonly, you can chmod() in

--Cheers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜