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. How do I hide the window title bar from QDockWidget
Forum Updated to NodeBB v4.3 + New Features

How do I hide the window title bar from QDockWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
window titleqdockwidget
34 Posts 7 Posters 12.4k Views 4 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.
  • L lansing

    @mrjj

    My doctwidget layout

    QDockWidget
    ----dockWidgetContents (vertical layout)
    --------QTabWidget
    ------------QTextEdit
    --------QTextEdit
    

    The dockWidgetContents is the layout of the dockWidget.

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

    Ok
    so on the vertical layout, set its margins to zero and see. default its 12 pixels.
    Im not sure if that is the case but it could explain the huge gap.
    setContentsMargins(0,0,0,0);

    L 1 Reply Last reply
    1
    • mrjjM mrjj

      Ok
      so on the vertical layout, set its margins to zero and see. default its 12 pixels.
      Im not sure if that is the case but it could explain the huge gap.
      setContentsMargins(0,0,0,0);

      L Offline
      L Offline
      lansing
      wrote on last edited by
      #19

      @mrjj

      The top gap does become smaller, but when docked, I still couldn't move the contents into the title bar area.

      alt text

      mrjjM 1 Reply Last reply
      0
      • L lansing

        @mrjj

        The top gap does become smaller, but when docked, I still couldn't move the contents into the title bar area.

        alt text

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

        @lansing
        Well when a widget is in a layout its not possible to move it.

        you could try to use
        https://doc.qt.io/qt-5/qdockwidget.html#titleBarWidget
        and then setFixedHeight(1);
        and see if that changes anything.

        L 1 Reply Last reply
        1
        • mrjjM mrjj

          @lansing
          Well when a widget is in a layout its not possible to move it.

          you could try to use
          https://doc.qt.io/qt-5/qdockwidget.html#titleBarWidget
          and then setFixedHeight(1);
          and see if that changes anything.

          L Offline
          L Offline
          lansing
          wrote on last edited by
          #21

          @mrjj

          This will be worse because now it's even harder to click and drag the widget.

          mrjjM 1 Reply Last reply
          0
          • L lansing

            @mrjj

            This will be worse because now it's even harder to click and drag the widget.

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

            @lansing
            Yes that was expected.
            But did it accept smaller size ?

            L 1 Reply Last reply
            0
            • mrjjM mrjj

              @lansing
              Yes that was expected.
              But did it accept smaller size ?

              L Offline
              L Offline
              lansing
              wrote on last edited by
              #23

              @mrjj

              My program crashed on run

              QWidget * titleBar = m_ui->myrDockWidget->titleBarWidget();
              titleBar->setFixedHeight(1);
              
              mrjjM 1 Reply Last reply
              0
              • L lansing

                @mrjj

                My program crashed on run

                QWidget * titleBar = m_ui->myrDockWidget->titleBarWidget();
                titleBar->setFixedHeight(1);
                
                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #24

                @lansing
                ah sorry my bad
                Docs says
                "Returns the custom title bar widget set on the QDockWidget, or nullptr if no custom title bar has been set."

                but we didnt anymore so its null. ok so not an option unless we do
                m_ui->myDockWidget->setTitleBarWidget(new QWidget(m_ui->myDockWidget));

                But you are right. Its too hard to hit if smaller so guess we just have to leave it.

                I just wonder where that space comes from as the examples don't have it.

                alt text

                B 1 Reply Last reply
                0
                • mrjjM mrjj

                  @lansing
                  ah sorry my bad
                  Docs says
                  "Returns the custom title bar widget set on the QDockWidget, or nullptr if no custom title bar has been set."

                  but we didnt anymore so its null. ok so not an option unless we do
                  m_ui->myDockWidget->setTitleBarWidget(new QWidget(m_ui->myDockWidget));

                  But you are right. Its too hard to hit if smaller so guess we just have to leave it.

                  I just wonder where that space comes from as the examples don't have it.

                  alt text

                  B Offline
                  B Offline
                  Bonnie
                  wrote on last edited by Bonnie
                  #25

                  @mrjj said in How do I hide the window title bar from QTabWidget:

                  I just wonder where that space comes from as the examples don't have it.

                  That must be the layout default margins...The OP mentioned using a vertical layout...

                  mrjjM 1 Reply Last reply
                  1
                  • B Bonnie

                    @mrjj said in How do I hide the window title bar from QTabWidget:

                    I just wonder where that space comes from as the examples don't have it.

                    That must be the layout default margins...The OP mentioned using a vertical layout...

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

                    @Bonnie
                    Also my thought but we did try
                    setContentsMargins(0,0,0,0);
                    higher up.

                    So maybe that space is really just the hidden titlebar, it just look bigger to me than the samples.

                    B L 2 Replies Last reply
                    0
                    • mrjjM mrjj

                      @Bonnie
                      Also my thought but we did try
                      setContentsMargins(0,0,0,0);
                      higher up.

                      So maybe that space is really just the hidden titlebar, it just look bigger to me than the samples.

                      B Offline
                      B Offline
                      Bonnie
                      wrote on last edited by Bonnie
                      #27

                      @mrjj said in How do I hide the window title bar from QTabWidget:

                      setContentsMargins(0,0,0,0);

                      I would guess that the OP call that on the widget, not the layout...
                      Ah...maybe not...
                      I'm not sure what's the current situation now. I thought the gap in the later picture would be that titlebar?

                      1 Reply Last reply
                      0
                      • mrjjM mrjj

                        @Bonnie
                        Also my thought but we did try
                        setContentsMargins(0,0,0,0);
                        higher up.

                        So maybe that space is really just the hidden titlebar, it just look bigger to me than the samples.

                        L Offline
                        L Offline
                        lansing
                        wrote on last edited by
                        #28

                        @mrjj

                        Yes it's the title bar

                        alt text

                        mrjjM 1 Reply Last reply
                        0
                        • L lansing

                          @mrjj

                          Yes it's the title bar

                          alt text

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

                          @lansing
                          Ok so thats as far as we can come as you cannot move tabWidget more up. :)

                          1 Reply Last reply
                          0
                          • mrjjM mrjj

                            Hi
                            What title bar ??

                            alt text

                            If you mean when you use it as a window so its shown with the normal border and title then you can do

                            setWindowFlags(Qt::Window | Qt::FramelessWindowHint);

                            YunusY Offline
                            YunusY Offline
                            Yunus
                            wrote on last edited by
                            #30

                            @mrjj is there any way to use Qt::FramelessWindowHint and giving resizeability to the widget at the same time. Because whenweused the Qt::FramelessWindowHint, widget is not able to be resizeable anymore ?

                            mrjjM 1 Reply Last reply
                            0
                            • YunusY Yunus

                              @mrjj is there any way to use Qt::FramelessWindowHint and giving resizeability to the widget at the same time. Because whenweused the Qt::FramelessWindowHint, widget is not able to be resizeable anymore ?

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

                              @Yunus
                              Hi
                              Sadly not. That flag removes the decorations. ( the frame) and those are used by the OS to resize.
                              It's possible to hand code it but it's hard work.
                              Often people use less code-intensive solution and allow resize from right, bottom corner only.
                              Using this class
                              https://doc.qt.io/qt-6/qsizegrip.html

                              1 Reply Last reply
                              1
                              • JonBJ Offline
                                JonBJ Offline
                                JonB
                                wrote on last edited by
                                #32

                                @Yunus , @mrjj
                                See https://forum.qt.io/topic/141510/how-to-make-framelesswindowhint-resizable

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

                                  Hi
                                  There is also
                                  https://github.com/dfct/TrueFramelessWindow
                                  which supports most features like resizing and dragging

                                  1 Reply Last reply
                                  2
                                  • L lansing

                                    I want to hide the default "window title" bar that's on top of the dockwidget, I couldn't find the answer anywhere.

                                    UPDATE: update to a more accurate title for future reference

                                    RokeJulianLockhartR Offline
                                    RokeJulianLockhartR Offline
                                    RokeJulianLockhart
                                    wrote on last edited by RokeJulianLockhart
                                    #34

                                    I want to hide the default "window title" bar that's on top of the dockwidget.

                                    @lansing, stackoverflow.com/revisions/21701604/1 should work:

                                    dockWidget->setTitleBarWidget(new QWidget());
                                    

                                    Otherwise, maybe follow stackoverflow.com/q/18918496.

                                    When using a forum, remember to tag the person you are responding to, in case they are not subscribed to the thread.

                                    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