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. Custom QWidgetAction To Differ on Vertical QToolBar and/or Different QToolButton Styles

Custom QWidgetAction To Differ on Vertical QToolBar and/or Different QToolButton Styles

Scheduled Pinned Locked Moved General and Desktop
qwidgetactionqtoolbarqcomboboxqtoolbuttonstyle
3 Posts 2 Posters 2.0k Views
  • 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.
  • E Offline
    E Offline
    Erika
    wrote on 7 Jun 2016, 20:24 last edited by Erika 6 Jul 2016, 20:25
    #1

    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!

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 7 Jun 2016, 20:52 last edited by
      #2

      Hi,

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      E 1 Reply Last reply 8 Jun 2016, 14:20
      0
      • S SGaist
        7 Jun 2016, 20:52

        Hi,

        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.

        E Offline
        E Offline
        Erika
        wrote on 8 Jun 2016, 14:20 last edited by
        #3

        @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.

        1 Reply Last reply
        0

        2/3

        7 Jun 2016, 20:52

        • Login

        • Login or register to search.
        2 out of 3
        • First post
          2/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved