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. How to select multiple combo boxes in a QTableWidget
Forum Updated to NodeBB v4.3 + New Features

How to select multiple combo boxes in a QTableWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 2.0k 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.
  • E Offline
    E Offline
    elveatles
    wrote on last edited by
    #1

    Hello,
    What can I do to maintain a user's row selection in a QTableWidget when they are selecting combo box items?
    It's probably best to show in images:

    This is the selection I want:
    Selection

    This is what happens when I select a combo box in the table. The selection is lost and only the row that the combo box is in is selected:
    Table Combo Selection

    But if I select a combo box outside of the table, the selection is not lost:
    Outer Combo Selection

    How do I keep the selection while clicking a combo box inside the table? I want to be able to select multiple rows and change all the combo boxes in that selection to the same thing all at once. Any help is much appreciated.

    raven-worxR 1 Reply Last reply
    0
    • E elveatles

      Hello,
      What can I do to maintain a user's row selection in a QTableWidget when they are selecting combo box items?
      It's probably best to show in images:

      This is the selection I want:
      Selection

      This is what happens when I select a combo box in the table. The selection is lost and only the row that the combo box is in is selected:
      Table Combo Selection

      But if I select a combo box outside of the table, the selection is not lost:
      Outer Combo Selection

      How do I keep the selection while clicking a combo box inside the table? I want to be able to select multiple rows and change all the combo boxes in that selection to the same thing all at once. Any help is much appreciated.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @elveatles
      capture the key-press and -release events in the combobox so they do not get propagated to the parent (the list view widget) and update the selection.
      This can be done by calling accept() on the event in the event handler.

      Do you use an item delegate to create the comboboxes?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • E Offline
        E Offline
        elveatles
        wrote on last edited by
        #3

        Thanks raven. I'm using QTableWidget::setCellWidget.

        1 Reply Last reply
        0
        • E Offline
          E Offline
          elveatles
          wrote on last edited by
          #4

          Calling accept() on the events actually didn't work for me. Instead, I ended up overriding selectionCommand and returning QItemSelectionModel::NoUpdate if the column is the same column that my combo boxes are in.

          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