PDA

View Full Version : Floating windows constrained to within the MainWindow?



ntp
10th July 2007, 01:16
I would like to create an application where I can have frames/windows inside of a main window that the users would be allowed to resize and move as they wish but would be constrained to the main window. Java Swing has the concept of a JDesktopPane that does that. I looked at QDockWidget but those widgets are allowed to move outside of the main window.

Is there any way currently to do this without making my own? This would have to be able to run under the commercial license.

Thanks,
Nisha

guilugi
10th July 2007, 09:15
You can use QDockWidget, it seems to be the easiest solution :)

By the way, you can prevent docked widgets from floating outside of the mainwindow :


dockwidget->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable)

Just omit the feature
QDockWidget::DockWidgetFloatable

merlvingian
10th July 2007, 18:53
QWorkspace

ntp
10th July 2007, 19:41
guilugi:

Thanks. I tried it but I cannot move the window around or resize it. I did the following in my main.cpp. (I added the test widget which is just a simple wrapper around a QGLWidget to give the window a body. Even without it, it didn't work):



QDockWidget *dockWidget;
dockWidget = new QDockWidget(ui.frame);
dockWidget->setGeometry(QRect(40, 30, 120, 80));
dockWidget->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable);

GLTestWidget *glWidget = new GLTestWidget();
dockWidget->setWidget(glWidget);


merlvingian:

Thanks for the reference to QWorkspace. I'm looking at it now but I am not sure I understand the relationship between it and QMdiXXX widgets

-- Nisha

jpn
10th July 2007, 19:45
I am not sure I understand the relationship between it and QMdiXXX widgets
QMdiXXX is a replacement for QWorkspace in Qt 4.3.

ntp
10th July 2007, 20:11
QMdiArea looks like it has what I need. I assume that once I get into it, I'll be able to have some control over the subwindow's menus for maximize, minimize, etc.

It was as simple as this:



QMdiArea* mdiArea = new QMdiArea(ui.frame);
GLTestWidget *glWidget = new GLTestWidget();
mdiArea->addSubWindow(glWidget);


Thanks everyone!

Nisha