wxwidgets 在隐藏/显示子控件后调整大小调整器
我有一个wxWindow。里面有一个 wxBoxSize (垂直)。 sizer 有 3 个子控件。
我希望能够隐藏三个子控件之一,并让 sizer 及其父控件自动调整大小。例如,当我隐藏 sizer 的一个子控件时,窗口会减小 200 像素。
现在,我显示隐藏某些控件并调整窗口大小的方法如下所示:(硬编码,丑陋)
void GenUIAanleverOptionsDialog::OnToggleButtonShowLabels( wxCommandEvent& event )
{
if(this->btnShowLabels->GetValue())
{
this->pnlInfoLabels->Show(true);
this->SetSize(this->GetSize().GetWidth(), 573);
}
else
{
this->pnlInfoLabels->Show(false);
this->SetSize(this->GetSize().GetWidth(), 294);
}
}
I have an wxWindow. Inside there I've got a wxBoxSize (Vertical). The sizer has 3 child controls.
I want to be able to hide one of the three child controls, and have the sizer and its parent automaticly resize. For example when I hide one child control of the sizer, the window decreases by 200 pixels.
Right now my method of showing hiding certain controls, and resizing the window looks like this: (Hardcoded, fugly)
void GenUIAanleverOptionsDialog::OnToggleButtonShowLabels( wxCommandEvent& event )
{
if(this->btnShowLabels->GetValue())
{
this->pnlInfoLabels->Show(true);
this->SetSize(this->GetSize().GetWidth(), 573);
}
else
{
this->pnlInfoLabels->Show(false);
this->SetSize(this->GetSize().GetWidth(), 294);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现对我有用的解决方案是隐藏/显示包含面板的 Sizer。更改 Sizer 的可见性后,需要调用 Sizer 的方法 Layout()。
然而,这并没有调整父窗口的位置,因此还需要调用 wxWindow 的 Fit() 方法。
最终代码:
The solution I found working for me was to Hide/Show the Sizer that contained the panel. After changing the visibility of the Sizer, a call to the Sizer's method Layout() was necassary.
That however did not also adjust the position of the parent window, so a call to the wxWindow's Fit() method was necassary aswell.
Final code: