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. Troubles with 3 icons becoming one
Qt 6.11 is out! See what's new in the release blog

Troubles with 3 icons becoming one

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 6 Posters 1.7k Views 4 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 rock37

    @JoeCFD i do not understand

    JoeCFDJ Offline
    JoeCFDJ Offline
    JoeCFD
    wrote on last edited by
    #5

    @rock37 for example

    class ThreeIconsButton: public QPushButton
    {
    protected:
          void mousePressEvent(QMouseEvent * mouse_event) override;
    }
    
    1 Reply Last reply
    0
    • R rock37

      Hey folks,

      i've a stupid problem. i have 3 button where each one can be selected to activate a certain setting in the app. now my coworker wants to pack it into one icon so i only have one icon where i can click the icons and get a dropdown where you can see which of the icons is selected and select/deselect another one.

      How can i solve this issue, i have to say i'm a newbie in qt and don't have much experience with it, i would be glad if someone can help me out of my mysery.

      best regards,
      stuv

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #6

      @rock37 said in Troubles with 3 icons becoming one:

      now my coworker wants to pack it into one icon so i only have one icon where i can click the icons and get a dropdown where you can see which of the icons is selected and select/deselect another one

      You could do this with a QComboBox, where the items have icons and no text. You would have to see how it looked. You can tailor how items are drawn if you need to. If you are doing this on a menubar you would have to check it works there.

      Or you can go about it in the way @JoeCFD suggests, which is rather different.

      R 1 Reply Last reply
      1
      • JonBJ JonB

        @rock37 said in Troubles with 3 icons becoming one:

        now my coworker wants to pack it into one icon so i only have one icon where i can click the icons and get a dropdown where you can see which of the icons is selected and select/deselect another one

        You could do this with a QComboBox, where the items have icons and no text. You would have to see how it looked. You can tailor how items are drawn if you need to. If you are doing this on a menubar you would have to check it works there.

        Or you can go about it in the way @JoeCFD suggests, which is rather different.

        R Offline
        R Offline
        rock37
        wrote on last edited by
        #7

        @JonB The problem is that all 3 icons must be selectable.

        JonBJ Pl45m4P 2 Replies Last reply
        0
        • R rock37

          @JonB The problem is that all 3 icons must be selectable.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #8

          @rock37 You mean unlike a combobox you want to allow multiple items to be selected at the same time? Then you would want some kind of QListView/QListWidget to do it in a widget way.

          1 Reply Last reply
          1
          • R rock37

            @JonB The problem is that all 3 icons must be selectable.

            Pl45m4P Offline
            Pl45m4P Offline
            Pl45m4
            wrote on last edited by Pl45m4
            #9

            @rock37 said in Troubles with 3 icons becoming one:

            The problem is that all 3 icons must be selectable

            So "icon" = button?

            Selectable in which way? Selectable as you would select text with your cursor or just "activate" them like you would press a button to enable some option (toggle between them)?
            I think this is what you mean right?
            @JoeCFD probably misunderstood what you tried to say in your first post.
            You could go with some QComboBox widget as @JonB suggested or you create your own custom widget that fits your needs... and you can re-use it as you need at least two of them ;-)


            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

            ~E. W. Dijkstra

            R 1 Reply Last reply
            0
            • Pl45m4P Pl45m4

              @rock37 said in Troubles with 3 icons becoming one:

              The problem is that all 3 icons must be selectable

              So "icon" = button?

              Selectable in which way? Selectable as you would select text with your cursor or just "activate" them like you would press a button to enable some option (toggle between them)?
              I think this is what you mean right?
              @JoeCFD probably misunderstood what you tried to say in your first post.
              You could go with some QComboBox widget as @JonB suggested or you create your own custom widget that fits your needs... and you can re-use it as you need at least two of them ;-)

              R Offline
              R Offline
              rock37
              wrote on last edited by
              #10

              @Pl45m4 my chef told me it's possible to have mutliple selections possible with QToolBar, i just don't know how to add icons to a QToolBar.

              Pl45m4P 1 Reply Last reply
              0
              • R rock37

                @Pl45m4 my chef told me it's possible to have mutliple selections possible with QToolBar, i just don't know how to add icons to a QToolBar.

                Pl45m4P Offline
                Pl45m4P Offline
                Pl45m4
                wrote on last edited by Pl45m4
                #11

                @rock37

                Bosses tell many things... ;-)

                First you said "icons", then "buttons", which later should be selectable (exclusively or non exclusive?!)
                And now you're speaking of QToolBar?! Which is the parent widget where your "icons"/"buttons" are in.
                I assume these are QToolButtons then?!
                Would have helped to know that right at the beginning ;-)
                Can you please try to describe precisely what do you really need and what behavior you expect? Otherwise people will misunderstand things and provide inadequate answers


                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                ~E. W. Dijkstra

                R 1 Reply Last reply
                2
                • Pl45m4P Pl45m4

                  @rock37

                  Bosses tell many things... ;-)

                  First you said "icons", then "buttons", which later should be selectable (exclusively or non exclusive?!)
                  And now you're speaking of QToolBar?! Which is the parent widget where your "icons"/"buttons" are in.
                  I assume these are QToolButtons then?!
                  Would have helped to know that right at the beginning ;-)
                  Can you please try to describe precisely what do you really need and what behavior you expect? Otherwise people will misunderstand things and provide inadequate answers

                  R Offline
                  R Offline
                  rock37
                  wrote on last edited by
                  #12

                  @Pl45m4 Sorry for me to be so unclear, i have these 3 buttons and i want them to share one button where each icon is part of the dropdown that the first button is creating to be able to select at least one of the icons of the dropdown.

                  M 1 Reply Last reply
                  0
                  • R rock37

                    @Pl45m4 Sorry for me to be so unclear, i have these 3 buttons and i want them to share one button where each icon is part of the dropdown that the first button is creating to be able to select at least one of the icons of the dropdown.

                    M Offline
                    M Offline
                    mpergand
                    wrote on last edited by
                    #13

                    @rock37
                    Have a look here:
                    https://www.walletfox.com/course/customqtoolbutton.php

                    1 Reply Last reply
                    2
                    • S Offline
                      S Offline
                      SimonSchroeder
                      wrote on last edited by
                      #14

                      If you are using a QToolButton directly it has an option to turn on a dropdown menu: https://doc.qt.io/qt-6/qtoolbutton.html#ToolButtonPopupMode-enum

                      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