PDA

View Full Version : Indicating a folder when folder is empty in QTreeWidget using (+) sign



taamar
17th January 2010, 14:07
Hi,
I'm using QTreeWidget and want that the '+' sign will always appear,
to indicate a folder, even when the folder is empty.
How can I do this?

(I tried to insert an empty file but I don't want it to be shown,
so I used setHidden(true) and the '+' sign disappeared again)

and ideas?
thanks.
tami.

axeljaeger
19th January 2010, 22:35
You will have to subclass the model to reimplement bool QAbstractItemModel::hasChildren ( const QModelIndex & parent = QModelIndex() ) const [virtual]


But please do not do such things. There is a good reason why standard widgets behave the way they do. I respect that you want to increase the usability of your application by indicating a folder. But all other application indicate a folder by a folder icon and an empty folder by a folder icon without an expanding icon. Your application will be the only one that differs. This will confuse more than it helps: Oh, there is a plus, lets expand that folder. Oh, it does not work, looks like a bug. Maybe there is more bugs in that software, I shall better use a software with less bugs.