Custom QWidgetAction To Differ on Vertical QToolBar and/or Different QToolButton Styles
I know, its bad form to blend two questions into one, but one relies on the other, so I'm doing it anyways.
Question 1: I'd like to have a custom toolbar item which displays a combo box when the QToolBar is horizontal, and a button when the QToolBar is vertical. My current approach is to have a QWidgetAction with a default QWidget, which contains both a QComboBox and QToolButton. Registering with the QToolBar::orientationChanged() (via the initial parent), I toggle the visibility depending on the orientation. When the QToolButton is clicked, the QComboBox::showPopup is called; when the QComboBox is activated, the icon of the QToolButton is updated. Any suggestions for a better approach?
Question 2: In lieu of a better approach, I noticed adding a QToolButton directly to a QWidget (via a layout) results in a different default styling. (See image: http://i.imgur.com/Eb2dT51.png - the green is the QWidgetAction, while the purple is a normal QAction added to the toolbar. Both have their icons set to a filled in color). Any ideas how to make the QToolButton consistent with the normal QToolBar->addAction styling?
Thanks in advance for any suggestions!
Do you have any logic in that "dummy" widget ? If not then you can maybe simply remove the QWidgetAction/add the button when switching orientation and do the reverse when going back.
@SGaist Thanks. That's definitely another option. I suppose these approaches are as good as it gets for having a toolbar item auto-adjust to horizontal vs. vertical. Thanks again.