Floating Windows bound by MainWindow?
-
Folks,
I am trying to create a UI which has a movable floating window over the QMainWindow. I want a window that is restricted in its motion to the frame of the QMainWindow. I tried using the QDialog class to hold my UI element (a QLineEdge widget) as well the QDockWidget class but I cant seem to "contain" these elements within the bounds of the QMainWindow. These behave like top level windows that can be dragged anywhere on the screen. I want them to behave as children of the MainWindow. How can I do this? Thanks in Advance.. -
If I understand you right, you want "MDI":http://doc.qt.nokia.com/latest/mainwindows-mdi.html
-
The background of an MDI is an "QMdiArea,":http://doc.qt.nokia.com/4.7/qmdiarea.html which is an abstract scroll area. By default, it is no QGLWidget. Indisde the MDI area, you can place any widget as sub windown, which is then hosted inside a "QMdiSubWindow":http://doc.qt.nokia.com/4.7/qmdisubwindow.html
-
Using the QMdiArea as a container for my windows is a No-Go. What I tried to do is get a QGLWidget to cover the entire QMdiArea and have my text input widgets floating on top of it.
The problem is there does not seem to be a way to set my own layout on the QMdiArea object.The way it looks right now..The minimized window/widget on the left is my QGLWidget and the visible widget is my TextEdit.. I was trying to make my QGLWidget cover the entire MDI area and have the TextEdit float on top.. Fail :(
!http://img198.imageshack.us/img198/614/screenshotsrv.png(CurrentMdi Result)!The code for the app..
!http://img233.imageshack.us/img233/781/screenshot1mb.png!The closest I got to my goal was by using a QGraphicsView with a QGLWidget as my viewport and adding my Widgets to a QGraphicsScene. This way everything is being rendered in opengl and I overrode the drawbackground method on QGraphicsScene. This way, the background was my 3D OpenGL Model and the foreground were the widgets.. I got this approach from the QT Quarterly archives..This should have ended up looking like
!http://doc.qt.nokia.com/qq/qq26-openglwidgets2.png!
But the behavior of the Widgets in the QGraphicsScene seems to have changed since the original article was writte. They end up looking like the following. The widgets are not movable either, even when the move flags are set..
!http://img831.imageshack.us/img831/778/screenshot2te.jpg!Maybe I need to explain what I am trying to do. I am trying to create a UI vaguely similar to the concept of how Photoshop looks..The background will display the 3D OpenGl Object the user will manipulate.. The foreground will be the widgets that have the controls to manipulate the 3D Image. The widgets may be buttons, text edit boxes(for a command line interface) .. and so on..
!http://www.thebandfrom.com/wp-content/uploads/photoshop-ui.png!