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.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With