[Qt-interest] MID/SDI

Sean Harmer sean.harmer at maps-technology.com
Mon Jan 18 22:16:13 CET 2010


Hi,

John Weeks wrote:
> Still ramping up on a Qt port of my company's application...
> 
> Our application is more or less an IDE for making scientific
> 
> Presently we run on Macintosh more or less as an SDI application. We have
> lots of different kinds of windows, and a session can have zero to many
> windows of every type. The menu bar is changed to reflect whatever kind of
> window has the focus.
> 
> On Windows we run as an MDI application, with all these various window
> types inside an MDI window.
> 
> It is my sense that these choices reflect what people using these platforms
> generally want. So, my question...
> 
> Is it easy/possible to write a Qt application that can choose at run-time
> whether to be an MDI or SDI application?
> 
> In looking at the MDI and SDI examples, it seems like this is a pretty
> fundamental choice. The subwindows for an MDI application are
> QMdiSubWindows; the windows for a SDI application are QMainWindows (or
> something else derived from QWidget).
> 
> If this is possible, can you suggest a strategy?

Yes this is possible. In fact you can even offer the user a setting to 
change between MDI/SDI type setups dynamically at runtime.

Just put your application specific stuff in classes derived from QWidget 
then set your custom widgets as either children of QMainWindow with 
setCentralWidget() or as children of QMdiubWindow with 
QMdiSubWindow::setWidget().

To do this dynamically at runtime you just need to reparent your 
application-specific widgets.

Give it a whirl with a simple test app. I do not think you will find it 
that difficult to do (unless I am missing something) ;-)

Good luck,

Sean



More information about the Qt-interest-old mailing list