Results 1 to 4 of 4

Thread: QListView - To select a disabled item

  1. #1
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

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

  2. #2
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QListView - To select a disabled item

    Use delegate and then paint disabled check boxes (option.state in delegate paint() event - use additional information to determine if check boxes should be disabled/enabled ). That way internally those items are enabled but user sees them as disabled.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  3. #3
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QListView - To select a disabled item

    Ok, I have never used delegates, but it would seem worth checking out indeed. Thanks for the suggestion!

  4. #4
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QListView - To select a disabled item

    Ok, I have implemented or, at least, tried to implement a delegate solution (see https://github.com/opencor/opencor/b...ginswindow.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...


    Added after 25 minutes:


    Ok, I have just fixed the issue I mentioned above. Clearly still learning about (powerful) delegates... (https://github.com/opencor/opencor/c...471bae41044e03)
    Last edited by agarny; 10th July 2011 at 01:23.

Similar Threads

  1. How to select the dropped item in a QTreeWidget?
    By Olivier Berten in forum Qt Programming
    Replies: 1
    Last Post: 8th June 2010, 11:36
  2. Need to show a menu item with disabled look but functional
    By lalesculiviu in forum Qt Programming
    Replies: 4
    Last Post: 21st October 2009, 15:16
  3. can't select item in a QTreeWidget via code
    By zack in forum Qt Programming
    Replies: 1
    Last Post: 14th July 2009, 20:31
  4. QTreeWidget select item
    By ^NyAw^ in forum Qt Programming
    Replies: 7
    Last Post: 26th October 2007, 14:26
  5. Cannot select an item in QComboBox
    By Declan in forum Qt Programming
    Replies: 2
    Last Post: 19th April 2007, 08:08

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.