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. Toolbar spacer does not expand to the right corner
Forum Updated to NodeBB v4.3 + New Features

Toolbar spacer does not expand to the right corner

Scheduled Pinned Locked Moved Unsolved General and Desktop
34 Posts 5 Posters 5.5k Views 2 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.
  • VRoninV Offline
    VRoninV Offline
    VRonin
    wrote on last edited by VRonin
    #9

    I suspect the problem is not with the spacer widget but with something else in your code.
    We need to narrow down the list of suspects.
    Please answer the point 1 above and, in addition:

    1. what is the body of createComboBoxStyle?
    2. how do you create m_aboutAction?

    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
    ~Napoleon Bonaparte

    On a crusade to banish setIndexWidget() from the holy land of Qt

    T 1 Reply Last reply
    1
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #10

      Hi
      Just as a note.
      You could apply a style sheet

      spacer->setStyleSheet("QWidget{ background-color: rgb(178, 255, 34);}");

      so its clear how it's placed.

      T 1 Reply Last reply
      1
      • VRoninV VRonin

        I suspect the problem is not with the spacer widget but with something else in your code.
        We need to narrow down the list of suspects.
        Please answer the point 1 above and, in addition:

        1. what is the body of createComboBoxStyle?
        2. how do you create m_aboutAction?
        T Offline
        T Offline
        TommyTLC
        wrote on last edited by
        #11

        @VRonin ok so I have tried creating a new project with your minimal example and that works perfectly! The problem is now understanding what's causing the issue in my project.

        1. m_styleSwitcher = new QComboBox(this);
          m_styleSwitcher->addItem(m_defaultStyleAction->text(), Default);
          m_styleSwitcher->addItem(m_fusionStyleAction->text(), Fusion);
          m_styleSwitcher->addItem(QStringLiteral("VisualStudio2019 ") + m_themeBlueAction->text(), VS2019Blue);
          m_styleSwitcher->addItem(QStringLiteral("VisualStudio2019 ") + m_themeDarkAction->text(), VS2019Dark);
          m_styleSwitcher->addItem(QStringLiteral("VisualStudio2019 ") + m_themeLightAction->text(), VS2019Light);
          m_styleSwitcher->setCurrentIndex(static_cast<int>(m_appStyle));
          connect(m_styleSwitcher, SIGNAL(currentIndexChanged(int)), this, SLOT(styleIndexChanged(int)));
          return m_styleSwitcher;

        2. m_aboutAction is created in the .h file:

          QAction* m_aboutAction;

        1 Reply Last reply
        1
        • mrjjM mrjj

          Hi
          Just as a note.
          You could apply a style sheet

          spacer->setStyleSheet("QWidget{ background-color: rgb(178, 255, 34);}");

          so its clear how it's placed.

          T Offline
          T Offline
          TommyTLC
          wrote on last edited by
          #12

          @mrjj This might actually help understanding the cause of the issue. I have applied the style sheet to the spacer. When the window is in full screen mode I can correctly see the spacer object:

          visible spacer.PNG

          While having the application in a smaller window I do not see the style sheet:

          not visible spacer.PNG

          mrjjM 1 Reply Last reply
          0
          • T TommyTLC

            @mrjj This might actually help understanding the cause of the issue. I have applied the style sheet to the spacer. When the window is in full screen mode I can correctly see the spacer object:

            visible spacer.PNG

            While having the application in a smaller window I do not see the style sheet:

            not visible spacer.PNG

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #13

            @TommyTLC
            Ok so does it go into the >> or is then completely gone ?

            T 1 Reply Last reply
            0
            • mrjjM mrjj

              @TommyTLC
              Ok so does it go into the >> or is then completely gone ?

              T Offline
              T Offline
              TommyTLC
              wrote on last edited by
              #14

              @mrjj in the >> I only see my m_aboutAction. It looks like the spacer disappears when the application is not in full screen.

              mrjjM VRoninV 2 Replies Last reply
              0
              • T TommyTLC

                @mrjj in the >> I only see my m_aboutAction. It looks like the spacer disappears when the application is not in full screen.

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #15

                @TommyTLC
                That i have not seen before. :)
                Could you give your spacer object a name with setObjectName and
                then do
                ui->menubar->dumpObjectTree();
                (adjust to name)

                Then it will show all its sub objexts like

                QMenuBar::menubar 
                    QToolButton::qt_menubar_ext_button 
                    QMenu::menuMENU 
                        QAction:: 
                    QMenu::menuMENU2 
                        QAction:: 
                    QMenu::menuMENU3 
                        QAction:: 
                

                just to see if its still in or really gone. Its kinda hard for a widget to just fall off as it's owned by the parent.

                T 1 Reply Last reply
                0
                • mrjjM mrjj

                  @TommyTLC
                  That i have not seen before. :)
                  Could you give your spacer object a name with setObjectName and
                  then do
                  ui->menubar->dumpObjectTree();
                  (adjust to name)

                  Then it will show all its sub objexts like

                  QMenuBar::menubar 
                      QToolButton::qt_menubar_ext_button 
                      QMenu::menuMENU 
                          QAction:: 
                      QMenu::menuMENU2 
                          QAction:: 
                      QMenu::menuMENU3 
                          QAction:: 
                  

                  just to see if its still in or really gone. Its kinda hard for a widget to just fall off as it's owned by the parent.

                  T Offline
                  T Offline
                  TommyTLC
                  wrote on last edited by
                  #16

                  @mrjj This is what I have done:

                  spacer->setObjectName("spacerName");
                  ui->m_fileToolBar->dumpObjectTree();

                  It looks like this function does not allow the use of "ui". If I follow the error's suggestion and use a pointer type toward m_fileToolBar I get another error saying that m_fileToolBar is not a member of the Ui::MainWindow class.

                  mrjjM 1 Reply Last reply
                  0
                  • T TommyTLC

                    @mrjj This is what I have done:

                    spacer->setObjectName("spacerName");
                    ui->m_fileToolBar->dumpObjectTree();

                    It looks like this function does not allow the use of "ui". If I follow the error's suggestion and use a pointer type toward m_fileToolBar I get another error saying that m_fileToolBar is not a member of the Ui::MainWindow class.

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #17

                    Hi
                    the name m_fileToolBar suggest to me its not in a UI
                    so its just
                    m_fileToolBar->dumpObjectTree();

                    T 1 Reply Last reply
                    0
                    • mrjjM mrjj

                      Hi
                      the name m_fileToolBar suggest to me its not in a UI
                      so its just
                      m_fileToolBar->dumpObjectTree();

                      T Offline
                      T Offline
                      TommyTLC
                      wrote on last edited by
                      #18

                      @mrjj Thank you! Here's the output (I have given my spacer object the name "spacerName"):

                      Qtitan::DockToolBar::
                      Qtitan::DockToolBarLayout::
                      Qtitan::DockToolBarExtension::
                      QMenu::
                      QAction::
                      Qtitan::ToolButton::
                      QWidgetAction::
                      QLineEdit::
                      QWidgetLineControl::
                      Qtitan::ToolButton::
                      QWidgetAction::
                      QSpinBox::
                      QLineEdit::qt_spinbox_lineedit
                      QWidgetLineControl::
                      QValidator::qt_spinboxvalidator
                      Qtitan::ToolButton::
                      QWidgetAction::
                      QWidget::spacerName

                      mrjjM 1 Reply Last reply
                      0
                      • T TommyTLC

                        @mrjj Thank you! Here's the output (I have given my spacer object the name "spacerName"):

                        Qtitan::DockToolBar::
                        Qtitan::DockToolBarLayout::
                        Qtitan::DockToolBarExtension::
                        QMenu::
                        QAction::
                        Qtitan::ToolButton::
                        QWidgetAction::
                        QLineEdit::
                        QWidgetLineControl::
                        Qtitan::ToolButton::
                        QWidgetAction::
                        QSpinBox::
                        QLineEdit::qt_spinbox_lineedit
                        QWidgetLineControl::
                        QValidator::qt_spinboxvalidator
                        Qtitan::ToolButton::
                        QWidgetAction::
                        QWidget::spacerName

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #19

                        @TommyTLC
                        Ok so it is still there :)
                        Then i would
                        qDebug() << "size" << qDebug() << spacer->geometry();
                        and it will show something like
                        QRect(747,339 75x23)

                        as it could be fun to see its location and size.

                        T 1 Reply Last reply
                        1
                        • mrjjM mrjj

                          @TommyTLC
                          Ok so it is still there :)
                          Then i would
                          qDebug() << "size" << qDebug() << spacer->geometry();
                          and it will show something like
                          QRect(747,339 75x23)

                          as it could be fun to see its location and size.

                          T Offline
                          T Offline
                          TommyTLC
                          wrote on last edited by TommyTLC
                          #20

                          @mrjj This is where my spacer is located/its size: QRect(0,0 1180x480)

                          mrjjM 1 Reply Last reply
                          0
                          • T TommyTLC

                            @mrjj This is where my spacer is located/its size: QRect(0,0 1180x480)

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by mrjj
                            #21

                            @TommyTLC
                            so its at o,0 and 1180 wide o.O and almost 500 in height.
                            but we clearly dont see that.
                            can you try
                            qDebug() << "vis" << spacer->isVisible();

                            i was wondering if this happens due to
                            spacer->setMinimumWidth(1180);
                            as i have seen widgets do odd stuff when not room enough.

                            T 1 Reply Last reply
                            0
                            • mrjjM mrjj

                              @TommyTLC
                              so its at o,0 and 1180 wide o.O and almost 500 in height.
                              but we clearly dont see that.
                              can you try
                              qDebug() << "vis" << spacer->isVisible();

                              i was wondering if this happens due to
                              spacer->setMinimumWidth(1180);
                              as i have seen widgets do odd stuff when not room enough.

                              T Offline
                              T Offline
                              TommyTLC
                              wrote on last edited by
                              #22

                              @mrjj vis false

                              mrjjM 1 Reply Last reply
                              0
                              • T TommyTLC

                                @mrjj vis false

                                mrjjM Offline
                                mrjjM Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on last edited by mrjj
                                #23

                                @TommyTLC
                                ok so its get hidden for some odd reason.
                                do you use the do anything to the spacer variable after it has been inserted ?
                                also try
                                spacer->show();
                                after its gone. ( like via a button)
                                and lets see what happens.

                                T 1 Reply Last reply
                                0
                                • mrjjM mrjj

                                  @TommyTLC
                                  ok so its get hidden for some odd reason.
                                  do you use the do anything to the spacer variable after it has been inserted ?
                                  also try
                                  spacer->show();
                                  after its gone. ( like via a button)
                                  and lets see what happens.

                                  T Offline
                                  T Offline
                                  TommyTLC
                                  wrote on last edited by
                                  #24

                                  @mrjj This is all I do with the spacer:

                                  QWidget* spacer = new QWidget();
                                  spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
                                  spacer->setMinimumWidth(1180);
                                  m_fileToolBar->addWidget(spacer);
                                  

                                  it gets created, I set the SizePolicy and the minimumWidth and then I assign it to the toolBar.

                                  mrjjM 1 Reply Last reply
                                  0
                                  • T TommyTLC

                                    @mrjj This is all I do with the spacer:

                                    QWidget* spacer = new QWidget();
                                    spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
                                    spacer->setMinimumWidth(1180);
                                    m_fileToolBar->addWidget(spacer);
                                    

                                    it gets created, I set the SizePolicy and the minimumWidth and then I assign it to the toolBar.

                                    mrjjM Offline
                                    mrjjM Offline
                                    mrjj
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #25

                                    @TommyTLC
                                    Ok so its not hidden by user code.
                                    Could you try a smaller minimum and see like
                                    spacer->setMinimumWidth(200);

                                    I know its not the goal but just to see if it still happens.

                                    VRoninV T 2 Replies Last reply
                                    0
                                    • T TommyTLC

                                      @mrjj in the >> I only see my m_aboutAction. It looks like the spacer disappears when the application is not in full screen.

                                      VRoninV Offline
                                      VRoninV Offline
                                      VRonin
                                      wrote on last edited by
                                      #26

                                      @TommyTLC said in Toolbar spacer does not expand to the right corner:

                                      in the >> I only see my m_aboutAction

                                      you do not see the style combo either?

                                      Did you overload resizeEvent?

                                      Does the "Configuration" label on the left have something special?

                                      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                                      ~Napoleon Bonaparte

                                      On a crusade to banish setIndexWidget() from the holy land of Qt

                                      T 1 Reply Last reply
                                      0
                                      • mrjjM mrjj

                                        @TommyTLC
                                        Ok so its not hidden by user code.
                                        Could you try a smaller minimum and see like
                                        spacer->setMinimumWidth(200);

                                        I know its not the goal but just to see if it still happens.

                                        VRoninV Offline
                                        VRoninV Offline
                                        VRonin
                                        wrote on last edited by
                                        #27

                                        @mrjj said in Toolbar spacer does not expand to the right corner:

                                        Ok so its not hidden by user code.

                                        If it goes into >> then it will be hidden. I'm not sure this test is conclusive

                                        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                                        ~Napoleon Bonaparte

                                        On a crusade to banish setIndexWidget() from the holy land of Qt

                                        1 Reply Last reply
                                        1
                                        • mrjjM mrjj

                                          @TommyTLC
                                          Ok so its not hidden by user code.
                                          Could you try a smaller minimum and see like
                                          spacer->setMinimumWidth(200);

                                          I know its not the goal but just to see if it still happens.

                                          T Offline
                                          T Offline
                                          TommyTLC
                                          wrote on last edited by
                                          #28

                                          @mrjj By changing the minimum size I see the spacer:

                                          visible spacer.PNG

                                          But the items to the right can still be hidden by resizing the window:

                                          not visible spacer.PNG

                                          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