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] Centering QToolButton in Vertical QToolBar
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Centering QToolButton in Vertical QToolBar

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 3.9k 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.
  • R Offline
    R Offline
    rizoritis
    wrote on 20 Jun 2013, 02:02 last edited by
    #1

    Hello,

    I created a vertical QToolBar outside of QDesigner and added various QToolButton widgets to the toolbar. I am finding it hard to horizontally align the buttons within the vertical toolbar. Right now they are all oriented on the left and it does not look to pleasing. I was thinking about using QVBoxLayout, but got stuck on how to put the layout into the toolbar, especially with separators. If anyone has a similar or completely different approach for centering the buttons please advise.

    Thanks!

    1 Reply Last reply
    0
    • R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 20 Jun 2013, 06:39 last edited by
      #2

      you can also create the QToolButtons by yourself, place them with a layout in a plane QWidget and "add this QWidget to the tool bar":http://qt-project.org/doc/qt-4.8/qtoolbar.html#addWidget.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rizoritis
        wrote on 20 Jun 2013, 11:09 last edited by
        #3

        [quote author="raven-worx" date="1371710345"]you can also create the QToolButtons by yourself, place them with a layout in a plane QWidget and "add this QWidget to the tool bar":http://qt-project.org/doc/qt-4.8/qtoolbar.html#addWidget. [/quote]

        I do not want to do this because , and correct me if I am wrong, there is no way to make a vertical toolbar on the left of the screen is you use Designer. I had to manually make it with code so I need a manual way of centering the icons in my vertical toolbar.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 20 Jun 2013, 11:16 last edited by
          #4

          yes and why is my advise not possible with "the coding way"?

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rizoritis
            wrote on 20 Jun 2013, 11:33 last edited by
            #5

            [quote author="raven-worx" date="1371726960"]yes and why is my advise not possible with "the coding way"?[/quote]

            Oh haha, apologies. I read your post wrong. That is what I believe I am trying to do however when I try to add my layout to the toolbar it says I can't add a layout to it, it must be a widget. I can do what you said and put them in a plane widget, but then how do I add a separator between them in the layout?

            Update: I got it to work, thanks a bunch. I just missed that middle step of throwing the layout in a widget. But I am still not sure how to add separators in between the buttons using this method...

            1 Reply Last reply
            0
            • R Offline
              R Offline
              raven-worx
              Moderators
              wrote on 20 Jun 2013, 11:37 last edited by
              #6

              instead of adding all tool buttons to the widget you should create for each tool button a wrapper-widget and add this to the toolbar.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0

              1/6

              20 Jun 2013, 02:02

              • Login

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