Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 disabled in a QTreeWidget ?

like image 229
Tangui Avatar asked Oct 19 '25 04:10

Tangui


1 Answers

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.

like image 101
hmuelner Avatar answered Oct 22 '25 05:10

hmuelner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!