Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tabify 3 QDockWidget

How can I create a tabified dock for 3 widgets in QMainWindow?

I'm using the code bellow:

widget1 = new QDockWidget(this);
widget1 ->setObjectName("name1");
addDockWidget(Qt::LeftDockWidgetArea, widget1);
widget2 = new QDockWidget(this);
widget2 ->setObjectName("name2");
addDockWidget(Qt::LeftDockWidgetArea, widget2);
tabifyDockWidget(widget2, widget1);
widget3 = new QDockWidget(this);
widget3->setObjectName("name3");
addDockWidget(Qt::LeftDockWidgetArea, widget3);
tabifyDockWidget(widget3, widget1);

This code is resulting in two docks: Dock 2 alone, and Dock 1 and 3 tabified.

like image 909
Victor Avatar asked Feb 15 '23 22:02

Victor


1 Answers

To fix, I just change the position of first and second parameters:

widget1 = new QDockWidget(this);
widget1 ->setObjectName("name1");
addDockWidget(Qt::LeftDockWidgetArea, widget1);

widget2 = new QDockWidget(this);
widget2 ->setObjectName("name2");
addDockWidget(Qt::LeftDockWidgetArea, widget2);
tabifyDockWidget(widget2, widget1);

widget3 = new QDockWidget(this);
widget3->setObjectName("name3");
addDockWidget(Qt::LeftDockWidgetArea, widget3);
tabifyDockWidget(widget1, widget3);
like image 165
Victor Avatar answered Mar 02 '23 15:03

Victor