Results 1 to 4 of 4

Thread: Single selection across multiple listsViews

  1. #1
    Join Date
    Jan 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Single selection across multiple listsViews

    Hello!
    I have tired googling this for a while, but been unsuccessful in finding any answer. (Or really anyone asking the same question). What I have found are selection policies and selection modes. But all this is for within a widget.
    http://www.qtcentre.org/threads/5781...2-QListWidgets does not help me as I will have to many lists. Worst case I can solve it that way, but preferably not.

    What I want to achieve is across multiple widgets a single selection across multiple QListViews. So if I select an item in a different list it will deselect all previous items.
    What I need is the following:
    Across all widgets only a single selection should be shown. I'm using a delegate so relying on focus instead of selection is ok.
    If I select an item in a list in a different widget, then when I go back to the item I had previously selected it should give me a callback. (This works if I use selectionChanged + clearing selection on focusOutEvent).

    Focus seems like it might be the solution, but also there I have tried to use focusOutEvent and focusInEvent to clear the selection/focus. But I have still not managed to get the result I want. (If I clear selection on focusOutEvent it won't have any selection at all it seems like).

    Help would be much appriciated!

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Single selection across multiple listsViews

    So selecting something in one view should deselect everything in all the other views?
    Or should all views then select the same thing?

    Cheers,
    _

  3. #3
    Join Date
    Jan 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: Single selection across multiple listsViews

    Quote Originally Posted by anda_skoa View Post
    So selecting something in one view should deselect everything in all the other views?
    Or should all views then select the same thing?

    Cheers,
    _
    It should "deselect" everything else. Although it doesn't necessarily have to be the selection system. As long as the requirements of being unique within all sub-widgets of a specified widget (or possibly application) and me getting a callback when it's selected.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Single selection across multiple listsViews

    You will need a mediator object that knows all QItemSelectionModels and connects to their selectionChanged signal.

    When one of the has a selection change, it needs to remember that it is now changing the selection, then deselect all other models, ignore their signals, then restore the normal mode.

    Cheers,
    _

Similar Threads

  1. Replies: 0
    Last Post: 23rd July 2015, 19:14
  2. Replies: 1
    Last Post: 31st October 2014, 20:45
  3. Have a single selection of item between 2 QListWidgets
    By salik89 in forum Qt Programming
    Replies: 5
    Last Post: 29th January 2014, 18:53
  4. Should I use multiple or a single model(s)?
    By Cotlone in forum Newbie
    Replies: 2
    Last Post: 7th May 2010, 03:39
  5. Single QGLContext across multiple QGLWidgets
    By pseudosig in forum Qt Programming
    Replies: 2
    Last Post: 22nd June 2008, 23:13

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
  •  
Qt is a trademark of The Qt Company.