Results 1 to 5 of 5

Thread: Need Advice on Good Widget for Defining Order of Items in a List

  1. #1
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Need Advice on Good Widget for Defining Order of Items in a List

    I'm pretty new to using the built-in Qt widgets.

    I have a list of six names. I want the user to be able to pick four of the six, and define an order for those four.

    There will be N sets of these lists. The lists are teams, with four team members active at a time. So the user picks a team with six players. Any previous choices need to be remembered, but the user can change which four on the team are active, and what order they're in.

    One way I thought of is to have four comboboxes with the same six items for each. The user then picks a different name for each or the four comboboxes. I'd have to indicate somehow when the same name was in two comboboxes.

    I can make that work, but maybe there are better ways? The "which 4 of the six" changes infrequently. The order of the "chosen 4" is likely to change frequently. The data I need from the widget is the "chosen 4" in the defined order.

    I think a really convenient way would allow the order to be changed by dragging something to the correct place in the four positions, but that might be too complicated.

    Thanks for any help!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Need Advice on Good Widget for Defining Order of Items in a List

    Hmm... QListWidget or QTreeWidget, optionally with checkboxes?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Need Advice on Good Widget for Defining Order of Items in a List

    Create one QListWidget, with six items.
    Next to it, you place 2 buttons, MoveUp and MoveDown (with a nice icon...).

    Select the name you want on top of the list and click MoveUp to get it there.
    Select the next name etc. etc.

    When done, click Done, or OK.
    Read the first 4 or all 6 items.

    This way you don`t have the trouble of indicating double items and copying between widgets.
    It`s also easier to the eyes, because there are less widgets and you can concentrate on the items (names).

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Need Advice on Good Widget for Defining Order of Items in a List

    I will suggest QTableWidget, with couple of custom QTableWidgetItems in the column cells, that would be nice (from user perspective).
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  5. #5
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Need Advice on Good Widget for Defining Order of Items in a List

    I'm trying out QTableWidget for this, the column headers are the team members. Each row has split times for the team members.

    Making the horizontal header "movable" seems to work nicely. But, I like the idea of having arrow icons to move the selected column left or right, since I'm not sure how well drag/drop will work on a tablet. Do I need to write the code to move the data to swap with the adjacent left or right column, or is there a "slicker" way?

    Also, if I keep the movable headers, can I keep the first column fixed, but allow all others to be movable?

    Thanks!

Similar Threads

  1. Replies: 1
    Last Post: 23rd April 2011, 18:33
  2. Defining widget regions sensitive to mouse events?
    By kachofool in forum Qt Programming
    Replies: 1
    Last Post: 29th December 2010, 02:37
  3. QFileDialog filename list order
    By joelthelion in forum Qt Programming
    Replies: 1
    Last Post: 28th January 2009, 15:58
  4. Right click list - some advice ?
    By aurelius in forum Qt Programming
    Replies: 5
    Last Post: 27th January 2009, 08:04
  5. Too slow adding & defining items to QTreeWidget
    By jnk5y in forum Qt Programming
    Replies: 16
    Last Post: 22nd April 2008, 21:26

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.