[Qt-interest] Title bar is not shown, if I add a widget in a Layout

Andre Somers andre at familiesomers.nl
Tue Dec 1 12:58:18 CET 2009


Santhosh Y wrote:
> Hi,
>
> When I add a QWidget, to a QLayout, it is removing title bar of my widget.
>
> For example.
> I tried adding a QMainWindow  to QHBoxLayout and it is not showing title 
> bar of QMainWindow.
>
> Becasuse of that, it is not easy to figure out the Widgets since 
> titlebar is missing.
>
> Is there any way, to show title bar even if I add in the layout.
>   
A title bar is shown (by the windowmanager) if your widget is a 
top-level widget. That is, if it does not have a parent. A widget that 
is inserted in a QLayout obviously is not a top level widget. It is part 
of the top level widget who's layout is managed by the QLayout you 
inserted the widget into. I also fail to see the point of having a 
QLayout manage the layout of something you hint the user *they* can manage.

There is one semi-exception, and that is an MDI situation. In that case, 
you have an area in your application where windows can exist. AFAIK, 
title bars are imitated by Qt in that scenario. If you want that, use a 
QMdiArea and use your widgets in there. However, a QLayout inside your 
MDI area doesn't make a lot of sense to me again.

André




More information about the Qt-interest-old mailing list