Troubles with 3 icons becoming one
-
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 -
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 -
here you see the 2 types of 3 different icons and each of the 3 icons should be each part of one icon where each icon must be selectable.
-
@rock37 add and get mouse event to this single icon and decide in which icon region the mouse position is located when mouse is clicked on the icon. Then you will know what to do next.
-
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@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.
-
@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.
-
@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 someQComboBoxwidget 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 ;-) -
@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 someQComboBoxwidget 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 ;-) -
@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.
Bosses tell many things... ;-)
First you said "icons", then "buttons", which later should be selectable (exclusively or non exclusive?!)
And now you're speaking ofQToolBar?! Which is the parent widget where your "icons"/"buttons" are in.
I assume these areQToolButtonsthen?!
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 -
Bosses tell many things... ;-)
First you said "icons", then "buttons", which later should be selectable (exclusively or non exclusive?!)
And now you're speaking ofQToolBar?! Which is the parent widget where your "icons"/"buttons" are in.
I assume these areQToolButtonsthen?!
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 -
@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.
-
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
