Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Creating a QComboBox with checkboxes within it
Forum Updated to NodeBB v4.3 + New Features

Creating a QComboBox with checkboxes within it

Scheduled Pinned Locked Moved Unsolved Qt for Python
6 Posts 3 Posters 1.4k Views 1 Watching
  • 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.
  • R Offline
    R Offline
    rssweiss
    wrote on 19 Dec 2023, 12:27 last edited by
    #1

    Hi guys,

    I'm using PyQt6.

    I'm trying to create a QComboBox that has checkboxes within it.

    So the user can select an item, but also can check or uncheck the box next to it.

    How do I do it?

    Thanks

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 19 Dec 2023, 17:18 last edited by
      #2

      Hi,

      Before diving further in the implementation details, can you explain the design decision for having checkboxes in a combo box ? That's pretty counterintuitive from a user perspective to have that kind of information hidden in such a control.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      R 1 Reply Last reply 25 Dec 2023, 09:06
      2
      • S SGaist
        19 Dec 2023, 17:18

        Hi,

        Before diving further in the implementation details, can you explain the design decision for having checkboxes in a combo box ? That's pretty counterintuitive from a user perspective to have that kind of information hidden in such a control.

        R Offline
        R Offline
        rssweiss
        wrote on 25 Dec 2023, 09:06 last edited by
        #3

        @SGaist
        Hi! Thanks for your quick reply!

        Here's an illustration:

        76b8dd28-4d2a-4e49-b144-8eba7d9cdb85-image.png

        Explanation:
        You press on the menu, it shows you a few options to select from. But also, you can un/check the options.

        This could be used for:
        I have a team of players, and I want to check the ones who will be assigned into the game, but then I want to select one of them to display his data on the screen.

        S J 2 Replies Last reply 25 Dec 2023, 09:18
        0
        • R rssweiss
          25 Dec 2023, 09:06

          @SGaist
          Hi! Thanks for your quick reply!

          Here's an illustration:

          76b8dd28-4d2a-4e49-b144-8eba7d9cdb85-image.png

          Explanation:
          You press on the menu, it shows you a few options to select from. But also, you can un/check the options.

          This could be used for:
          I have a team of players, and I want to check the ones who will be assigned into the game, but then I want to select one of them to display his data on the screen.

          S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 25 Dec 2023, 09:18 last edited by
          #4

          In the context of a menu, having checkboxes is fine as you also have the complete view of the possibilities.

          In the context of a team of players, I would rather expect to have a list view that I can go up and down at will where I can see what I have selected rather than having to use a combo box that I would need to open and re-open.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          R 1 Reply Last reply 26 Dec 2023, 12:47
          1
          • R rssweiss
            25 Dec 2023, 09:06

            @SGaist
            Hi! Thanks for your quick reply!

            Here's an illustration:

            76b8dd28-4d2a-4e49-b144-8eba7d9cdb85-image.png

            Explanation:
            You press on the menu, it shows you a few options to select from. But also, you can un/check the options.

            This could be used for:
            I have a team of players, and I want to check the ones who will be assigned into the game, but then I want to select one of them to display his data on the screen.

            J Offline
            J Offline
            JonB
            wrote on 25 Dec 2023, 09:44 last edited by
            #5

            @rssweiss
            As @SGaist says use a QListView here. A combobox is intended to pick a single item, not put checks against multiple items.

            1 Reply Last reply
            1
            • S SGaist
              25 Dec 2023, 09:18

              In the context of a menu, having checkboxes is fine as you also have the complete view of the possibilities.

              In the context of a team of players, I would rather expect to have a list view that I can go up and down at will where I can see what I have selected rather than having to use a combo box that I would need to open and re-open.

              R Offline
              R Offline
              rssweiss
              wrote on 26 Dec 2023, 12:47 last edited by
              #6

              @SGaist said in Creating a QComboBox with checkboxes within it:

              In the context of a menu, having checkboxes is fine as you also have the complete view of the possibilities.

              In the context of a team of players, I would rather expect to have a list view that I can go up and down at will where I can see what I have selected rather than having to use a combo box that I would need to open and re-open.

              @JonB said in Creating a QComboBox with checkboxes within it:

              @rssweiss
              As @SGaist says use a QListView here. A combobox is intended to pick a single item, not put checks against multiple items.

              Alright, thank you guys!

              1 Reply Last reply
              0

              1/6

              19 Dec 2023, 12:27

              • Login

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