Open air-bash opened 1 year ago
Hi @r-bash thank you for checking out QtAwesome! Regarding what you want to achieve, I think the kwarg that needs to be passed is active
to toggle between icons. So basically code could do something like:
# Toggle
toggle_icon = qta.icon('fa5s.home', active='fa5s.balance-scale',
color_off='black',
color_off_active='blue',
color_on='orange',
color_on_active='yellow')
toggle_button = QtWidgets.QPushButton(toggle_icon, 'Toggle')
toggle_button.setCheckable(True)
With that you should see something like:
Some other examples that show this behavior are the piece of code commented as Styling
and the one commented as Stack icons
. Let us know if the info above helps!
Note: Not totally sure if this should be modified in the example or if there is an issue with the selected
vs active
option. What do you think @ccordoba12 ?
Not totally sure if this should be modified in the example or if there is an issue with the selected vs active option
There could be. So, what does the selected
option do?
There could be. So, what does the selected option do?
Hoped you would know 😅 , but anyhow I will give this a more in dept check then :+1: From a quick check seems like two different icon modes one for when the icon is clicked or hovered and the other when is actually selectable/selected 🤔
Hoped you would know :sweat_smile:
Haha, sorry, no idea!
Hi @dalthviz and @ccordoba12!
Big thank you for a quick response :smiley:
Okay, so I thought that "selected" for an icon means the same as "checked" for a button. So if the button is setCheckable(True)
, setAutoExclusive(True)
and it is checked it means that the icon will be in "selected" mode and will show icon of the state.
Under "selected" mode I understand that if for example we have two groups of buttons and basicaly they are working like a radio buttons (setCheckable(True)
and setAutoExclusive(True)
- only one button of the group can be selected). :dizzy_face: So, if we push one button of a first group it will be selected all the time till next button of the group will be selected instead of.
I am thinking that "Active" works differently. I am not sure and please correct me if I am wrong but I think that "active" mode keeps the icon active all the time till another object will be clicked anywhere. :sweat_smile:
Please look at below gifs:
toggle_icon = qta.icon('ph.house', active='ph.check-square',
color_off='black',
color_off_active='blue',
color_on='orange',
color_on_active='green')
toggle_button = QPushButton(parent=parent, icon=toggle_icon, text=btn + ' Toggle')
toggle_button.setAutoExclusive(True)
toggle_button.setCheckable(True)
Thanks for the feedback and testing @r-bash ! Seems more and more to me that we have an issue here with the selected
option. In case you would like to give it a try and debug what could be happening, I think the related code that parses the options is here:
Hello,
I've got:
and I am trying to create a QPushButton which will be changing the icon on a "selected" mode/state but unfortunatelly it is not working. In other words, I am trying to create toggle QPushButton. To create the QPushButton I've taken the example from your documentation( https://qtawesome.readthedocs.io/en/latest/usage.html#examples):
Could I ask you for help? Thanks