Make sure a generic window (e.g. wxPanel) is created with a valid size
Such windows will not be shown and are ignored by Qt if added directly as children to another window not managed by any sizer.
This commit is contained in:
parent
b231522fef
commit
098161c4de
1 changed files with 11 additions and 2 deletions
|
|
@ -350,6 +350,8 @@ bool wxWindowQt::Create( wxWindowQt * parent, wxWindowID id, const wxPoint & pos
|
|||
// that a generic control, like wxPanel, is being created, so we need a very
|
||||
// simple control as a base:
|
||||
|
||||
wxSize initialSize = size;
|
||||
|
||||
if ( GetHandle() == nullptr )
|
||||
{
|
||||
if ( style & (wxHSCROLL | wxVSCROLL) )
|
||||
|
|
@ -364,6 +366,13 @@ bool wxWindowQt::Create( wxWindowQt * parent, wxWindowID id, const wxPoint & pos
|
|||
}
|
||||
else
|
||||
m_qtWindow = new wxQtWidget( parent, this );
|
||||
|
||||
// The default size of a generic control (e.g. wxPanel) is (0, 0) when created and
|
||||
// is ignored by Qt unless the widget is already assigned a valid size or is added
|
||||
// to a QLayout to be managed with. The value 20 seems to be the default under wxMSW.
|
||||
// Do not pass 'initialSize' to CreateBase() below, as it will be taken as the minimum
|
||||
// size of the control, which is not the intention here.
|
||||
initialSize.SetDefaults(wxSize(20, 20));
|
||||
}
|
||||
|
||||
if ( !wxWindowBase::CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
|
||||
|
|
@ -375,11 +384,11 @@ bool wxWindowQt::Create( wxWindowQt * parent, wxWindowID id, const wxPoint & pos
|
|||
if ( pos != wxDefaultPosition )
|
||||
p = pos;
|
||||
|
||||
DoMoveWindow( p.x, p.y, size.GetWidth(), size.GetHeight() );
|
||||
DoMoveWindow( p.x, p.y, initialSize.GetWidth(), initialSize.GetHeight() );
|
||||
|
||||
PostCreation();
|
||||
|
||||
return ( true );
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxWindowQt::PostCreation(bool generic)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue