View Full Version : Qworkspace

20th July 2006, 12:44
Hye every body,

I'm developping an application that I want it to be MDI, just like QtDesigner V4 (in workspace mode), with some docked windows.

But I do not know how to instense a QWorkspace as main windows.

Does anyone know how could I?

Should I developp my own widget? If I must, how do you do it ?

Thanks for your help

21st July 2006, 07:58
You can't instantiate a QWorkspace as main window. I bet instantiating it as top level window would'nt help it because there would be no wxay to add docks...
Here is the way to go :

QMainWindow *pMain = new QMainWindow;

QWorkspace *pWorkspace = new QWorkspace(pMain);

//add your dock stuff here


21st July 2006, 10:41
Thanks for your help and that's exactly the problem I against actually.
But I do code in Python (with PyQt from riverbankcomputing), and here is what I did:

class MainWindow (QtGui.QMainWindow):
def __init__ (self, parent=None):
QtGui.QMainWindow.__init__ (self, parent)

self.workspace = QtGui.QWorkspace ()
self.setCentralWidget (self.workspace)

self.connect (self.workspace, QtCore.SIGNAL ("windowActivated (QWidget *)"), self.updateMenus)
self.windowMapper = QtCore.QSignalMapper (self)
self.connect (self.windowMapper, QtCore.SIGNAL ("mapped (QWidget *)"),
self.workspace, QtCore.SLOT ("setActiveWindow (QWidget *)"))

self.createActions ()
self.createMenus ()
self.createToolBars ()
self.createDockWindows () #<= Here is my problem
self.updateMenus ()
self.readSettings ()

If I do create the DockWindow, that do not work anymore...

I would prefere to do the same thing with QtDesigner, so that I quiet do not have to code with Qt :P

PS: this code came from the samples given by trolltech, and compile in Python by RiverBank

21st July 2006, 15:45
How do you setup your dock widgets???
You say the problem occurs in a function but you don't show the code...

Anyway, if you want to do it through designer, there's one way only : hack...
You must modify the content of your *.ui file by hand, at least at the beginning and AVOID selecting the QWorkspace widget (designer would crash...)

I've attached an example ui file, try it out...

24th July 2006, 10:37
Sorry my mistake that I do not show the code :P

But I choose to do it "manually", and not with QtDesigner, because I tried tha same sort of solution that you propose with your .ui, but "pyuic" the compiler of '.ui' in python, do not seems to very like workspace... so I can't use it :'(

However, thanks for your help.