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. Dock button on Menu bar
Forum Updated to NodeBB v4.3 + New Features

Dock button on Menu bar

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 7.3k 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.
  • A Offline
    A Offline
    aureshinite
    wrote on last edited by
    #1

    I have an application with multiple QDockWidget, and I want to add the possibility to dock the widget back to his default area. Right now I am using a button inside the window, but I want to use a button on the menu bar, where close|minimize|maximize are usually located. Is it possible to add custom buttons on the menu bar of QDockWidget? If not, I want to use the build-in "Restore" windows button , but I don't seems to find any way to enable it via Qt::WindowFlags.

    Thanks

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sigrid
      wrote on last edited by
      #2

      Do you mean the titlebar of the QDockWidget and not the menubar? If so, then you can set a custom titlebar to the QDockWidget using "setTitleBarWidget()":http://doc.qt.nokia.com/latest/qdockwidget.html#setTitleBarWidget and add your buttons to that titlebar. Does that give you what you need?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        aureshinite
        wrote on last edited by
        #3

        I meant the title bar. I tried what you said and yes it allows to set customs bars. The only issue now is that I am lazy :) and I don't want to recreate the default title bar on my own just to add a button. I also guess it is privately implemented, So I can extract the private implementation and just add the buttons I need. Do you know where is it located??

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          My guess - I did not check - would be that you should be able to use QStyle to draw the title bar. The source where the QDockWindow title bar is drawn should be easy enough to find on your own.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sigrid
            wrote on last edited by
            #5

            The titlebar is indeed privately implemented when the QDockWidget is docked. When the dockwidget is floating, it is using the native titlebar as documented "here":http://doc.qt.nokia.com/latest/qdockwidget.html#setTitleBarWidget

            You have no control over the native titlebar, so you can't modify the titlebar when the dockwidget is floating. If you need to do so, then you need to create a custom titlebar.

            If you only need to modify the titlebar when the QDockWidget is docked however, you can try modifying it using the style as Andre suggested.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              aureshinite
              wrote on last edited by
              #6

              Ok I am going to design a widget for my title bar. In the first place I wanted to be able to dock a floating Dockwidget with a simple click.

              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