0

Here is my code:

QDockWidgetTest::QDockWidgetTest(QWidget *parent)
: QMainWindow(parent)
{
    QDockWidget* dockWidget = new QDockWidget();
    QTabWidget* tabWidget = new QTabWidget();
    tabWidget->addTab(new QWidget(), "1");
    tabWidget->addTab(new QWidget(), "2");
    dockWidget->setWidget(tabWidget);
    addDockWidget(Qt::DockWidgetArea::LeftDockWidgetArea , dockWidget);

    QWidget* widget = new QWidget();
    QHBoxLayout* layout = new QHBoxLayout();
    layout->addWidget(new QLabel("content"));
    widget->setLayout(layout);
    layout->setSpacing(0);
     
    //set central widget stylesheet
    QColor whiteColor(255, 255, 255);
    QString styleSheet = QString("QWidget { background-color: %1 }").arg(whiteColor.name());
    widget->setStyleSheet(styleSheet);
    
    setCentralWidget(widget);
    
    showMaximized();

}

When centeralwidget has stylesheet, the border of QDockWidget will become wider, here's how it looks:

Result

How to solve it?

zebra
  • 1
  • 1
  • Does this answer your question? [Qt stylesheet of dock area splitter](https://stackoverflow.com/questions/26717957/qt-stylesheet-of-dock-area-splitter) – Abderrahmene Rayene Mihoub Jun 07 '23 at 15:50
  • The area you have a rectangle around is the QMainWindow's separator, see these as well: [Customizing QDockWidget](https://doc.qt.io/qt-6/stylesheet-examples.html#customizing-qdockwidget) ,[Remove margin space from QDockWidget in QMainWindow](https://stackoverflow.com/questions/21452494/remove-margin-space-from-qdockwidget-in-qmainwindow), [How can I change the width of a QMainWindow separator without it affecting the QDockWidget](https://stackoverflow.com/questions/4751594/how-can-i-change-the-width-of-a-qmainwindow-separator-without-it-affecting-the-q) – Abderrahmene Rayene Mihoub Jun 07 '23 at 15:58

0 Answers0