Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions
[SOLVED] QListView - To select a disabled item
I have a form that contains a QListView which is populated with checkable items. Some of those items are disabled to make it visually clear to the user that they can't be checked/unchecked.
Now, I want to be able to provide the user with additional information about a particular item, be it enabled or not. If the item is enabled, it's simple, all I need to do is to handle the currentChanged signal of the selectionModel of my QListView object. This, however (and obviously?), doesn't work for disabled items.
So, how could I allow the user to 'select' a disabled item so that I can provide him with additional about that item?
DenisKormalev last edited by
You can implement custom delegate, which will do pseudo-disabling (so element is enabled, but can't be checked and is drawn diffrently (greyed out for example)).
Yes, that's what I was also told in another forum and what I implemented or, at least, tried to implement ( see https://github.com/opencor/opencor/blob/master/src/pluginswindow.cpp ). It kind of works in that I get the behaviour I am after, but the drawing of the items (be they 'enabled' or 'disabled') doesn't look native (as is the case without the use of a delegate). For example, on Windows 7, without the delegate I get a 'transparent' blue while with the delegate I get an 'opaque' blue. So, I am close, but not quite there yet...
Ok, I have just fixed the issue I mentioned above. Clearly still learning about (powerful) delegates... ( https://github.com/opencor/opencor/commit/5334d6b3c6f150643d1ede14b3471bae41044e03 )