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. QDockWidget sizing borders
Qt 6.11 is out! See what's new in the release blog

QDockWidget sizing borders

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 2 Posters 2.3k Views 3 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by
    #3

    @Axel-Spoerl Any thoughts?

    1 Reply Last reply
    0
    • Axel SpoerlA Offline
      Axel SpoerlA Offline
      Axel Spoerl
      Moderators
      wrote on last edited by
      #4

      Hi David,
      that's quite interesting. The dockwidget becomes frameless, if Qt assumes that the window manager will draw native window decoration. It assumes so on Windows and MacOS, as well as Linux, provided that the window system is neither X11, nor wayland.
      So you must actually be working on Windows or MacOS, but for some reason the OS won't decorate the floating dock.
      I can't reproduce that here. It's either a corner case triggering a bug in Qt, or preventing the window manager from doing its job.
      Not sure if this helps you though.

      Software Engineer
      The Qt Company, Oslo

      1 Reply Last reply
      0
      • PerdrixP Offline
        PerdrixP Offline
        Perdrix
        wrote on last edited by Perdrix
        #5

        I've been struggling to reproduce it here - I added a title bar widget to one of the dock widget in the sample, but that behaved as it should...

        Strange that rebuilding an already released version of the code results in different behaviour than running the release binary!!?
        That's really odd!

        1 Reply Last reply
        0
        • PerdrixP Offline
          PerdrixP Offline
          Perdrix
          wrote on last edited by Perdrix
          #6

          Here's the entire code for the DockWidget in question:

          picturelist.h

          #pragma once
          
          #include "ui/ui_PictureList.h"
          
          namespace DSS
          {
          
          	class PictureList : public QDockWidget, public Ui::PictureList
          	{
          		friend class StackingDlg;
          		typedef QDockWidget
          			Inherited;
          		
          		Q_OBJECT
          
          	public:
          		PictureList(QWidget* parent = nullptr);
          		~PictureList();
          
          	private:
          		QLabel* dockTitle;
          
          #if QT_VERSION < 0x060601		// Shouldn't need this in QT 6.6.1
          	inline void setDSSClosing() { dssClosing = true; }
          
          	protected:
          		void closeEvent(QCloseEvent* event);
          
          	private:
          		bool dssClosing;
          #endif
          
          	};
          }
          

          picturelist.cpp

          #include "stdafx.h"
          #include "picturelist.h"
          namespace DSS
          {
          	PictureList::PictureList(QWidget* parent) :
          		QDockWidget(parent),
          		dockTitle{ new QLabel(this) }
          	{
          		setupUi(this);
          		tableView->horizontalHeader()->setSortIndicator(1, Qt::AscendingOrder);
          		tableView->horizontalHeader()->setSortIndicatorShown(true);
          
          		dockTitle->setToolTip(tr("Double click here to dock/undock the image list"));
          
          		//
          		// Set an informative title bar on the dockable image list with a nice gradient
          		// as the background (like the old "listInfo" static control).
          		// 
          		QSize size{ 625, 25 };
          		dockTitle->setObjectName("dockTitle");
          		dockTitle->setMinimumSize(size);
          		dockTitle->resize(size);
          		dockTitle->setStyleSheet(QString::fromUtf8("QLabel {"
          			"background: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, "
          			"stop:0 rgba(138, 185, 242, 0), stop:1 rgba(138, 185, 242, 255))}"));
          		setTitleBarWidget(dockTitle);
          	}
          
          	PictureList::~PictureList()
          	{}
          
          #if QT_VERSION < 0x060601		// Shouldn't need this in QT 6.6.1
          	//
          	// The user may not close the undocked window, but once DSS has set the 
          	// closing flag a closeEvent must be accepted (default) otherwise DSS 
          	// shutdown never completes.
          	//
          	void PictureList::closeEvent(QCloseEvent* event)
          	{
          		if (!dssClosing) event->ignore();
          	}
          #endif
          }
          

          if I uncomment the setTitleBarWidget(dockTitle); line it works as expected (i.e. the dock widget has sizing borders when undocked), except of course that the title bar isn't set as I want.

          D.

          1 Reply Last reply
          0
          • Axel SpoerlA Offline
            Axel SpoerlA Offline
            Axel Spoerl
            Moderators
            wrote on last edited by
            #7

            Hi David,
            looking into this. The frame width isn't DPI scaled.
            That can be fixed. Need to investigate, why a title bar widget causes the dock widget to be frameless though.

            Software Engineer
            The Qt Company, Oslo

            1 Reply Last reply
            0
            • Axel SpoerlA Offline
              Axel SpoerlA Offline
              Axel Spoerl
              Moderators
              wrote on last edited by
              #8

              Hi David,
              looking into this. The frame width isn't DPI scaled.
              That can be fixed. Need to investigate, why a title bar widget causes the dock widget to be frameless.

              Software Engineer
              The Qt Company, Oslo

              1 Reply Last reply
              0
              • PerdrixP Offline
                PerdrixP Offline
                Perdrix
                wrote on last edited by Perdrix
                #9

                Perhaps you may need to do a SetWindowLongPtr() for the window when you un-dock it, adding the style flag WS_SIZEBOX:

                WS_SIZEBOX 0x00040000L The window has a sizing border. Same as the WS_THICKFRAME style.

                LONG_PTR style = GetWindowLongPtr(hwnd, GWL_STYLE);
                style |= WS_SIZEBOX;
                std::ignore = SetWindowLongPtr(hwnd, GWL_STYLE, style);
                
                SetWindowPos(hwnd,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_DRAWFRAME);
                
                //show window after updating
                ShowWindow(hwnd, SW_SHOW);
                

                and turn that flag off when re-docking the window

                1 Reply Last reply
                1
                • Axel SpoerlA Offline
                  Axel SpoerlA Offline
                  Axel Spoerl
                  Moderators
                  wrote on last edited by
                  #10

                  Dock widgets have been handled on a platform abstracted layer. They have a fair share of my love, but not all my time unfortunately. I need to wrap my head around why this is happening.

                  Software Engineer
                  The Qt Company, Oslo

                  1 Reply Last reply
                  0
                  • PerdrixP Offline
                    PerdrixP Offline
                    Perdrix
                    wrote on last edited by
                    #11

                    An item of information that may well help. A release build works (has sizing borders) but a debug build doesn't. ????

                    David

                    1 Reply Last reply
                    0
                    • Axel SpoerlA Offline
                      Axel SpoerlA Offline
                      Axel Spoerl
                      Moderators
                      wrote on last edited by
                      #12

                      Interesting!
                      Could you throw a qInfo() << "Application Style:" << QApplication::style(); into the code and see if there's a difference between debug and release mode?

                      Software Engineer
                      The Qt Company, Oslo

                      1 Reply Last reply
                      0
                      • PerdrixP Offline
                        PerdrixP Offline
                        Perdrix
                        wrote on last edited by
                        #13

                        Debug build:
                        Application Style: QFusionStyle(0x25b8c40, name = "fusion")
                        Release build:
                        Application Style: QFusionStyle(0x552360, name = "fusion")

                        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