WXWIDGETS试图填充整个区域
wxWidgets trying to fill whole area
当我尝试使用wxwidgets准备GUI时,我遇到了问题。我想创建一些按钮,这些按钮涵盖文本框下的整个区域。
程序启动时看起来不错,但是当我想水平调整它时,按钮不移动。有什么想法吗?
mainFrame::mainFrame(std::string title) : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(800, 600))
{
wxBoxSizer* vertSizer = new wxBoxSizer(wxVERTICAL);
vertSizer->Add(
new wxTextCtrl(this, -1, "My text", wxDefaultPosition, wxSize(100,80), wxTE_MULTILINE),
1, // vertically stretchable
wxEXPAND | wxALL, // horizontally stretchable, borders all around
10); // Add text box to parent sizer
wxBoxSizer* horizSizer = new wxBoxSizer(wxHORIZONTAL); // Make child sizer, will contain buttons
wxSizerFlags ButtonFlags(1); // Make controls stretch hoizontally (to cover entire sizer area)
ButtonFlags.Expand().Center().Border(wxALL,10); // Make controls expand vertically, add border
horizSizer->Add(new wxButton(this,123,"OK"), ButtonFlags); // Add first button
horizSizer->Add(new wxButton(this, 124,"Abort"), ButtonFlags); // Add second button
horizSizer->Add(new wxButton(this, 125,"Ignore"), ButtonFlags); // Add third button
vertSizer->Add(horizSizer); // Add child sizer to parent sizer
SetSizerAndFit(vertSizer);
}
发生这种情况,因为您没有告诉主sizer( vertSizer
)生长 horizSizer
以填充所有可用空间,因此您需要将 wxSizerFlags().Expand()
添加到一个,但最后一行以解决此问题。
此外,使用ButtonFlags.Expand().Center()
没有意义:您可以展开或居中,但不能同时进行中心,因此请选择一个。最后,DoubleBorder()
比Border(wxALL, 10)
。
相关文章:
- 在c++中用vector填充一个简单的动态数组
- 如何使用用户输入在C++中正确填充2D数组
- 如何找到大小'x'数组是否完全填充,在C++?
- Cuda C++:设备上的Malloc类,并用来自主机的数据填充它
- 通过for循环使用用户输入填充列表
- 将QGraphicsItem的移动区域限制在多边形区域内
- 根据用户输入用字母填充矢量,并将"开始"和"结束"放在四肢
- 如何正确填充在堆上分配的二维数组?
- 将数字转换为填充字符串
- 有没有办法在一行中填充矢量图
- 用C++中的数字和条件填充向量
- 用真值填充矢量
- 使用结构成员指针在C++中填充结构
- 有没有一种优雅而快速的方法来测试整数中的 1 位是否位于连续区域
- 查找要填充区域的矩形的大小
- 在图像上的矩形区域之外填充黑色
- 如何调用 GetAltMonthNames 来填充外部区域设置月份字符串的安全数组
- WXWIDGETS试图填充整个区域
- 如何选择一个像魔杖一样的区域,并使用OpenCV进行泛洪填充
- 用互联网浏览器的客户端区域填充窗口的客户端区域