views:

33

answers:

2

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 ?

A: 

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

Koteswara sarma
I'm dealing with user interface, not filesystem rights !
Tangui
+1  A: 

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.

hmuelner
I would try this with unsetting the ItemIsSelectable flag. This would leave it (and presumably the rest of the tree) enabled, but not allow the user to select that particular item.
Caleb Huitt - cjhuitt
Thanks for your answers, but it doesn't work neither. At best, the line is not highlighted, but you are still on it (a dotted border is visible).
Tangui