Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-51359

QDockWidget default title not respecting setContentsMargins

    XMLWordPrintable

Details

    Description

      If you call setContentsMargins on a dock widget, the default title bar remains left aligned and at the fixed width, leaving unusually awkward spacing to the left. If the dockwidget is floating, this is a non-issue, with margins added as expected.

      Simple example:

      #include <QtWidgets\QApplication>
      #include <QtWidgets\QMainWindow>
      #include <QtWidgets\QDockWidget>
      
      int main(int argc, char *argv[])
      {
      	QApplication app(argc, argv);
      	app.setApplicationName("Dock Margins Example");
      	QMainWindow mainWin;
      	// setup widgets
      	QDockWidget exampleDock(&mainWin);
      	QWidget dockContents;
      	dockContents.setStyleSheet(QStringLiteral("background: #FFFFFF;")); // contents colouring
      	exampleDock.setWidget(&dockContents);
      	mainWin.addDockWidget(Qt::LeftDockWidgetArea, &exampleDock);
      	exampleDock.setWindowTitle("Example Dock");
      	exampleDock.setContentsMargins(30, 30, 30, 30);
      	mainWin.show();
      	return app.exec();
      }
      

      Additionally, the top margin in the dock widget is ignored while docked (its set as the same as title's height), but is as-expected while floating.

      It may be related to QTBUG-2104, however it is unclear how to retrieve and re-arrange the default title bar.

      Attachments

        For Gerrit Dashboard: QTBUG-51359
        # Subject Branch Project Status CR V

        Activity

          People

            peppe Giuseppe D'Angelo
            erika Erika
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There is 1 open Gerrit change