PDA

View Full Version : QMainWindow (ForceTabbedDocks)



baray98
14th August 2007, 18:54
I have 4 dockWidgets in my app and I want them to be "forced tabbed Docks" when they are docked in the main window to begin with . I did not declare any mainWidget in my main window ( i am not sure if it is ok ), I want my user to have the option to move the dock windows around but once the user dock it it should be a tabbed Docks mode.

code below at constructor ( this class inherits QMainwindow)


setDockOptions(QMainWindow::AnimatedDocks|
QMainWindow::AllowTabbedDocks|
QMainWindow::ForceTabbedDocks);
//DockWidget No 1.
QDockWidget *dock = new QDockWidget(QObject::tr("Sensor 1 - 12"), this);
dock->setAllowedAreas( Qt::RightDockWidgetArea);
ptrTrendPlotter1 = new TrendPlotter(dock,TrendPlotter::sensor1to12);

dock->setWidget(ptrTrendPlotter1);
addDockWidget(Qt::RightDockWidgetArea, dock);

//DockWidget No 2.
dock = new QDockWidget(QObject::tr("Sensor 13 - 24"), this);
dock->setAllowedAreas( Qt::RightDockWidgetArea);
ptrTrendPlotter2 = new TrendPlotter(dock,TrendPlotter::sensor13to24);

dock->setWidget(ptrTrendPlotter2);
addDockWidget(Qt::RightDockWidgetArea, dock);

//DockWidget No 3.
dock = new QDockWidget(QObject::tr("Sensor 25 - 36"), this);
dock->setAllowedAreas( Qt::RightDockWidgetArea);
ptrTrendPlotter3 = new TrendPlotter(dock,TrendPlotter::sensor25to36);

dock->setWidget(ptrTrendPlotter3);
addDockWidget(Qt::RightDockWidgetArea, dock);

//DockWidget No 4
dock = new QDockWidget(QObject::tr("Sensor 37 - 48"), this);
dock->setAllowedAreas(Qt::RightDockWidgetArea);
ptrTrendPlotter4 = new TrendPlotter(dock,TrendPlotter::sensor37to48);

dock->setWidget(ptrTrendPlotter4);
addDockWidget(Qt::RightDockWidgetArea, dock);



please help,

baray98

marcel
14th August 2007, 19:15
Connect a slot to the QDockWidget::topLevelChanged signal.
When the parameter is false, then the widget is docked and youi can changed its features to features() & (~QDockWidget::DockWidgetFloatable).

Regards

baray98
14th August 2007, 20:40
thanks for the quick reply but my first problem is that in my code i have attached them all on leftDockArea hoping that the four widget will be forcetabbedDocks by my mainWindow but it did'nt happen the output is four dockwidget evenly displayed in my mainWindow.

please help,

baray98

marcel
14th August 2007, 20:54
Aa, ok. I see now.
Do you set fixed sizes/maximum sizez for the docks and/or widgets vontained by them?
F. e. what does the TrendPlotter constructor?

Regards

baray98
14th August 2007, 21:06
i did not set fixed sizes/maximum sizez for the docks and/or widgets vontained by them.

should i set them to some sizes so that forcetabbedDocks feature will kick in?

baray98

headhunter_pl
2nd December 2008, 10:21
I have similar problem with dock widgets. AFAIK this is added as a bug, but it'll be solved in some future release :/...

Pritpal Bedi
20th November 2009, 20:25
Hi

I run into the same problem.
Luckily there is a solution
...
...
dock->setWidget(ptrTrendPlotter4);
addDockWidget(Qt::RightDockWidgetArea, dock);

// First give all <dock>s as dock1,2,3,4
// Then
tabifyDockWidget( dock1, dock2 );
tabifyDockWidget( dock2, dock3 );
tabifyDockWidget( dock3, dock4 );

// A cruid method but works

Regards
Pritpal Bedi