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. Placing widgets in a toolbar created in QtDesigner.
Forum Updated to NodeBB v4.3 + New Features

Placing widgets in a toolbar created in QtDesigner.

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.4k Views 1 Watching
  • 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.
  • J Offline
    J Offline
    jc-denton
    wrote on last edited by
    #1

    So I had to figure out that it is not possible to place any widget in a toolbar using the designer. I wonder if it is just the Designers gui or if it is a limitation of the ui XML format. So then I place the toolbar manually using

    @QAction * QToolBar::insertWidget ( QAction * before, QWidget * widget )@

    I wonder about the return type, what exactly does this method return? IMHO void would be appropriate

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      No, it returns a QAction* that is associated with that widget. All items on a toolbar (or a menu, for that matter) are represented by QAction objects. That includes items that are widgets. You should check, but I think that the action returned is actually a [[doc:QWidgetAction]].

      You can use this action to put it in a [[doc:QActionGroup]] for instance.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jc-denton
        wrote on last edited by
        #3

        Thx for the Quick Replay!

        bq. You should check, but I think that the action returned is actually a QWidgetAction.

        Yes it is :)

        @QAction *action = toolbar->addWidget(myFontComboBox);
        QWidgetAction *widgetAction = dynamic_cast<QWidgetAction *>(action);
        assert(widgetAction);
        assert(dynamic_cast<QFontComboBox *>(widgetAction->defaultWidget())
        == myFontComboBox
        );@

        Does this mean I could place an action (or a QWidgetAction) into the toolbar in the designer and then just programmatically set the the desired widget?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          I have tried, but I could not find an easy way to do that. The problem is that you can't seem to use the promotion feature for QActions. So, I fear that you will just have to add your widget completely from code.

          1 Reply Last reply
          0

          • Login

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