Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] QListView - To select a disabled item
QtWS25 Last Chance

[SOLVED] QListView - To select a disabled item

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 4.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    agarny
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • A Offline
        A Offline
        agarny
        wrote on last edited by
        #3

        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...

        1 Reply Last reply
        0
        • A Offline
          A Offline
          agarny
          wrote on last edited by
          #4

          Ok, I have just fixed the issue I mentioned above. Clearly still learning about (powerful) delegates... ( https://github.com/opencor/opencor/commit/5334d6b3c6f150643d1ede14b3471bae41044e03 )

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved