Nominate our 2022 Qt Champions!

[SOLVED] QListView - To select a disabled item

  • Hi,

    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?

    Cheers, Alan.

  • 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 ). 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... ( )

Log in to reply