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. [Solved] Design a toolbar/widget in a separate .ui and add it to the QMainWindow

[Solved] Design a toolbar/widget in a separate .ui and add it to the QMainWindow

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 5.7k 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.
  • J Offline
    J Offline
    JulienMaille
    wrote on 13 Jan 2012, 09:22 last edited by
    #1

    Hi all,
    I have an application that load some plugins and I would like one of these plugins to add a new QToolbar when loaded.
    Is it possible to define this toolbar with Designer in a standalone .ui and then use it from my plugin (not dynamically with QUiLoader)?

    Same question with a QDockWidget.

    Thanks a lot for your help!

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on 13 Jan 2012, 11:48 last edited by
      #2

      Yes, this is possible. If you use resources, make sure the they're "initialized":/doc/qt-4.8/resources.html#using-resources-in-the-application eventually.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JulienMaille
        wrote on 13 Jan 2012, 12:05 last edited by
        #3

        I don't understand the link with resources?

        Regarding my original question: how do I build a ui with the top-level widget beeing a QToolbar in Designer?

        1 Reply Last reply
        0
        • J Offline
          J Offline
          JulienMaille
          wrote on 13 Jan 2012, 20:21 last edited by
          #4

          I edited a ui to keep nothing but the QToolbar. It's still possible to open and edit it with Designer. I don't know if it is a correct way to work, is it?
          @<?xml version="1.0" encoding="UTF-8"?>
          <ui version="4.0">
          <class>toolBar</class>
          <widget class="QToolBar" name="toolBar">
          <property name="geometry">
          <rect>
          <x>0</x>
          <y>0</y>
          <width>552</width>
          <height>273</height>
          </rect>
          </property>
          <property name="windowTitle">
          <string>toolBar</string>
          </property>
          <action name="actionSample_1">
          <property name="text">
          <string>sample action</string>
          </property>
          </action>
          <action name="actionSample_2">
          <property name="text">
          <string>sample #2</string>
          </property>
          </action>
          <addaction name="actionSample_1"/>
          <addaction name="actionSample_2"/>
          </widget>
          <resources/>
          <connections/>
          </ui>@

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on 13 Jan 2012, 22:28 last edited by
            #5

            Ah, I see. A single [[Doc:QToolBar]] cannot be edited in Qt Designer. But to be honest, it doesn't give you much benefit. It's so easy to add actions with icons to a toolbar programmatically that it's not worth the work in a graphical design tool. addAction(), insertAction(), add/insertSeparator() are your friends here.

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • J Offline
              J Offline
              JulienMaille
              wrote on 20 Jan 2012, 08:52 last edited by
              #6

              The idea was to let someone else design the toolbar without a line of code.
              But I found a solution. I created a mainwindow, added a toolbar. Then edited the xml to remove everything but the toolbar.
              Now I have a ui that can still be edited by Designer.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on 20 Jan 2012, 10:19 last edited by
                #7

                Nice trick! Thank's for sharing!

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply
                0

                1/7

                13 Jan 2012, 09:22

                • Login

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