Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can not control the position of a QToolbar within a QTabWidget
Qt 6.12 LTS is out! See what's new in the release blog

Can not control the position of a QToolbar within a QTabWidget

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 3 Posters 5.5k 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
    #5

    Hi,

    Except that you are currently adding that toolbar under your QTabWidget and not at the bottom of the widget inside the tab.

    Since you want different tabs to have different tool bars, you should consider making a base "tab widget" class that contains what you need and that you can configure.

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

    cheopsC 1 Reply Last reply
    0
    • JonBJ JonB

      @cheops

      I try to place a QToolbar within a QTabWidget

      // Add toolbar to Cloud Viewer tab widget
      ui->tabCloudViewer->layout()->addWidget(cloudViewerToolbar);
      

      I take these statements to indicate that ui->tabCloudViewer is the QTabWidget. Are you saying it is a page-widget on the QTabWidget? What type is it?

      cheopsC Offline
      cheopsC Offline
      cheops
      wrote on last edited by
      #6

      @JNBarchan
      No, ui->tabCloudViewer is a page on a QTabWidget with the name tabWidget...

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

        OK, thanks for the clarification.

        In that case, you can use insertWidget so you can prepend 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
        • SGaistS SGaist

          Hi,

          Except that you are currently adding that toolbar under your QTabWidget and not at the bottom of the widget inside the tab.

          Since you want different tabs to have different tool bars, you should consider making a base "tab widget" class that contains what you need and that you can configure.

          cheopsC Offline
          cheopsC Offline
          cheops
          wrote on last edited by
          #8

          @SGaist

          Hi,
          my problem ist, that I'm not able to configure the tab widget in a way, that the toolbar appears at the top of the tab page... So to create a new class wouldnt change anything, because I would also in such a case not be able to configure the tab page in the way I want...

          Or am I completely wrong?

          JonBJ 1 Reply Last reply
          0
          • cheopsC cheops

            @SGaist

            Hi,
            my problem ist, that I'm not able to configure the tab widget in a way, that the toolbar appears at the top of the tab page... So to create a new class wouldnt change anything, because I would also in such a case not be able to configure the tab page in the way I want...

            Or am I completely wrong?

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #9

            @cheops
            @SGaist is telling you that you can have the toolbar at the top:

            // Add toolbar to Cloud Viewer tab widget
            ui->tabCloudViewer->layout()->addWidget(cloudViewerToolbar);
            

            Use insertWidget instead of addWidget. addWidget always adds at end.

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

              The widget you should have as tab should basically be:

              • A QWidget with
              • A QVBoxLayout and
              • Your VTK widget inside that layout.

              And in that case you can insert the QToolBar as proposed.

              Or you can make a custom widget with the same content plus a method that would handle adding/setting a QToolBar in that tab.

              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
              • JonBJ JonB

                @cheops
                @SGaist is telling you that you can have the toolbar at the top:

                // Add toolbar to Cloud Viewer tab widget
                ui->tabCloudViewer->layout()->addWidget(cloudViewerToolbar);
                

                Use insertWidget instead of addWidget. addWidget always adds at end.

                cheopsC Offline
                cheopsC Offline
                cheops
                wrote on last edited by
                #11

                @JNBarchan Class QLayout has no member insertWidget?

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

                  QBoxLayout::insertWidget. QBoxLayout is the base class of QVBoxLayout and QHBoxLayout.

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

                  cheopsC 1 Reply Last reply
                  1
                  • SGaistS SGaist

                    QBoxLayout::insertWidget. QBoxLayout is the base class of QVBoxLayout and QHBoxLayout.

                    cheopsC Offline
                    cheopsC Offline
                    cheops
                    wrote on last edited by
                    #13

                    @SGaist
                    I tried to create a new widget class based on MainWindow, where I can configure all things I need very easy in QtDesigner, and I can easily insert this widget with

                    cloudViewer *cv = new cloudViewer;
                    ui->tabWidget->addTab(cv, "3D Viewer");
                    

                    ... I think, this is the simplest way for my needs, or is there somthing wrong with this solution in you opinion?

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

                      I don't see anything particularly wrong here.

                      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
                      • Unsolved