QAction from QToolBar focus behaviour
Currently I am working on an interface using QAction items from a QToolBar. I understand that QAction objects are not QWidget elements, although they get a "button" representation when I add them into my toolbar.
Now, when I click on any QAction item icon (in this context), it seems that the focus is captured by that item. As the QAction is not a button, not even a QWidget, how can I release the focus from it?
Thanks for your help.
PS: I tried using setChecked() and toggle() methods with no luck.
Maybe clearFocus ?
Hope it helps
clearFocus() is not available for the QAction class so I used it with the QToolBar object with no luck.
The effect I am trying to avoid is very curious. I noticed that the focus/checked mark only appears when I click any QAction for the first time, then a subtle square remains on them. If I click on the toolbar or any other place, the mark around the QAction buttons used doesn't disappear, therefore it shouldn't be a focus reference.
Here is a low resolution example. Pay attention to the Cancel and the Gear icons "focus" effect. The blue button doesn't have it.
regarding the checkmark issue are you using any stylesheet style?
Try also this:
foreach( QToolButton* btn, toolBar->findChildren<QToolButton*>() ) btn->setFocusPolicy( Qt::NoFocus );
Well, in fact I set a basic stylesheet definition to the toolbar just to redefine the background color. I will remove it temporarily just to find out if that is the cause of the problem.
Thank you for your suggestion, I will give it a try.
Ok, I tried removing the stylesheet instruction and it didn't work. The foreach instruction neither made any effect.
I know this is a very subtle issue. I can live with it, but it's more about curiosity... I mean, what is the cause of this behaviour?
Anyway, thank you for the support.
PS: I am testing this code from an Android tablet. Maybe is this a collateral issue of using QWidgets in Android?