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]How to center toolbuttons in horizontal toolbar?
Qt 6.11 is out! See what's new in the release blog

[solved]How to center toolbuttons in horizontal toolbar?

Scheduled Pinned Locked Moved General and Desktop
16 Posts 2 Posters 8.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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #7

    You should set the policy on the widgets, not the toolbar

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

    1 Reply Last reply
    0
    • A Offline
      A Offline
      aze473
      wrote on last edited by
      #8

      oh wow, so i just change it into spacerWidget->SetSizePolicy ?
      Im gonna try this right away.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        aze473
        wrote on last edited by
        #9

        [quote author="SGaist" date="1400570992"]You should set the policy on the widgets, not the toolbar[/quote]
        i tried this but it didnt work..am i still doing something wrong?

        @void BitcoinGUI::createToolBars()
        {
        QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
        QWidget *spacerWidget = new QWidget(this);
        spacerWidget>setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
        spacerWidget->setVisible(true);
        toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
        toolbar->addWidget(spacerWidget);
        toolbar->addAction(overviewAction);
        toolbar->addAction(sendCoinsAction);
        toolbar->addAction(receiveCoinsAction);
        toolbar->addAction(historyAction);
        toolbar->addAction(addressBookAction);
        toolbar->addWidget(spacerWidget);
        @

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #10

          You need two spacer widgets, otherwise you are just moving it from left to right

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

          1 Reply Last reply
          0
          • A Offline
            A Offline
            aze473
            wrote on last edited by
            #11

            [quote author="SGaist" date="1400707308"]You need two spacer widgets, otherwise you are just moving it from left to right[/quote]

            So i cannot use toolbar->addWidget(spacerWidget);
            twice?
            I have to make like a spacerwidget2?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #12

              No you can't, addWidget doesn't mean "copy that widget in the toolbar" (you can't copy widgets by the way nor any QObject derived class)

              So yes you have to create another spacer widget

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

              1 Reply Last reply
              0
              • A Offline
                A Offline
                aze473
                wrote on last edited by
                #13

                Thank you so much for all of your time and help! I really appreciate it.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #14

                  You're welcome !

                  Did you got it working ?

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

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    aze473
                    wrote on last edited by
                    #15

                    [quote author="SGaist" date="1400775959"]You're welcome !

                    Did you got it working ?[/quote]
                    Yes it works perfectly

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #16

                      Nice ! Then please update the thread title prepending [solved] so other forum users may know a solution has been found :)

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

                      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