[Qt-interest] setLayout for QMainWindow

Andreas Pakulat apaku at gmx.de
Tue Jan 20 09:38:15 CET 2009


On 20.01.09 15:52:57, Steven Woody wrote:
> On Tue, Jan 20, 2009 at 3:12 PM, J-P Nurmi <jpnurmi at gmail.com> wrote:
> > On Tue, Jan 20, 2009 at 5:21 AM, Steven Woody <narkewoody at gmail.com> wrote:
> >>
> >> Hi,
> >>
> >> Does it make any sense if I call setLayout() member for a QMainWindow?
> >
> > You're on the right track. QMainWindow has its own private layout to handle
> > toolbars, dock widgets, status bar etc. so it doesn't make sense, indeed.
> > The main window layout is described in QMainWindow documentation.
> >
> 
> Thank you!  And, I am thinking that if QMainWindow can override the
> setLayout() method and raise a exception when it is invoked, thinks
> will be more clear and less confusing.

Not really, as Qt doesn't use exceptions and more importantly its
technically not possible (in Qt4). setLayout is non-virtual so you can't
override it easily and being sure your overridden method is always called.
All it takes is a cast to QWidget, or some function that takes a QWidget as
input and calls setLayout.

Besides, nobody stops you from writing your own mainwindow layouting class
and use that instead of the normal layout class that QMainWindow uses.

Andreas

-- 
You don't become a failure until you're satisfied with being one.



More information about the Qt-interest-old mailing list