作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用外部 XRC 方法通过 wxFormBuilder 实现我的用户界面。
我正在尝试以这种方式实现一个卡在 wxStaticBoxSizer 上的面板数组:
MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size) {
wxXmlResource::Get()->LoadFrame((wxFrame*)this, (wxWindow*)NULL , wxT("MyFrame1"));
wxStaticBoxSizer* almacenador = (wxStaticBoxSizer*)FindItem(XRCID("Contenedor"));
if (!almacenador){
cout << "Error cargando sizer!" << endl << flush;
}
wxXmlResource::Get()->LoadPanel( (wxWindow*)almacenador , wxT("MyPanel6"));
wxXmlResource::Get()->LoadPanel( (wxWindow*)almacenador , wxT("MyPanel6"));
wxXmlResource::Get()->LoadPanel( (wxWindow*)almacenador , wxT("MyPanel6"));
SetTitle(title);
SetIcon(wxICON(appicon));
SetSize(size);
SetPosition(pos);
Show(true);
}
从“main”函数加载资源的地方
wxXmlResource::Get()->Load("rc/resource2.xrc");
行。当启动我的程序时它可以工作,但我在任何地方都看不到这三个面板。
这是我的 XRC 文件:
主框架:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<resource xmlns="http://www.wxwindows.org/wxxrc" version="2.3.0.1">
<object class="wxFrame" name="MyFrame1">
<style>wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL</style>
<size>283,401</size>
<title></title>
<centered>1</centered>
<aui_managed>0</aui_managed>
<object class="wxPanel" name="m_panel1">
<style>wxTAB_TRAVERSAL</style>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<option>0</option>
<flag>wxEXPAND</flag>
<border>5</border>
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<option>0</option>
<flag>wxALL|wxALIGN_BOTTOM</flag>
<border>5</border>
<object class="wxStaticText" name="m_label_Nombre1">
<label>Nombre</label>
<wrap>-1</wrap>
</object>
</object>
<object class="sizeritem">
<option>1</option>
<flag>wxEXPAND|wxTOP|wxRIGHT|wxLEFT</flag>
<border>5</border>
<object class="wxTextCtrl" name="m_text_Nombre">
<value></value>
</object>
</object>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALIGN_TOP|wxEXPAND</flag>
<border>5</border>
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<option>0</option>
<flag>wxALL|wxALIGN_BOTTOM</flag>
<border>5</border>
<object class="wxStaticText" name="m_label_Apellidos">
<label>Apellidos</label>
<wrap>-1</wrap>
</object>
</object>
<object class="sizeritem">
<option>1</option>
<flag>wxTOP|wxRIGHT|wxLEFT</flag>
<border>5</border>
<object class="wxTextCtrl" name="m_text_Apellidos">
<value></value>
</object>
</object>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxEXPAND</flag>
<border>5</border>
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<option>0</option>
<flag>wxALL|wxALIGN_BOTTOM</flag>
<border>5</border>
<object class="wxStaticText" name="m_label_Edad">
<label>Edad</label>
<wrap>-1</wrap>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALIGN_BOTTOM|wxALIGN_RIGHT|wxTOP|wxRIGHT|wxLEFT</flag>
<border>5</border>
<object class="wxSpinCtrl" name="m_spin_Edad">
<style>wxSP_ARROW_KEYS</style>
<value>0</value>
<min>0</min>
<max>10</max>
</object>
</object>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxEXPAND | wxALL</flag>
<border>5</border>
<object class="wxStaticLine" name="m_staticline1">
<style>wxLI_HORIZONTAL</style>
</object>
</object>
<object class="sizeritem">
<option>1</option>
<flag>wxEXPAND</flag>
<border>5</border>
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<option>1</option>
<flag>wxALL|wxEXPAND</flag>
<border>5</border>
<object class="wxRadioBox" name="m_radioBox_Sexo">
<label>Sexo</label>
<selection>0</selection>
<content>
<item>Hombre</item>
<item>Mujer</item>
</content>
<dimension>1</dimension>
</object>
</object>
<object class="sizeritem">
<option>1</option>
<flag>wxEXPAND|wxALL</flag>
<border>5</border>
<object class="wxStaticBoxSizer">
<orient>wxVERTICAL</orient>
<label>Preferencias</label>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<object class="wxCheckBox" name="m_checkBox_Cocacola">
<label>Cocacola</label>
<checked>0</checked>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<object class="wxCheckBox" name="m_checkBox_FantaNaranja">
<label>Fanta naranja</label>
<checked>0</checked>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<object class="wxCheckBox" name="m_checkBox_FantaLimon">
<label>Fanta Limon</label>
<checked>0</checked>
</object>
</object>
</object>
</object>
</object>
</object>
<object class="sizeritem">
<option>1</option>
<flag>wxEXPAND</flag>
<border>5</border>
<object class="wxStaticBoxSizer" name="Contenedor">
<orient>wxVERTICAL</orient>
<label>Contenedor</label>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<object class="wxButton" name="m_button4">
<label>MyButton</label>
<default>0</default>
</object>
</object>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALIGN_BOTTOM</flag>
<border>5</border>
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<object class="wxButton" name="m_button_Guardar">
<label>Guardar</label>
<default>0</default>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<object class="wxButton" name="m_button_Limpiar">
<label>Limpiar</label>
<default>0</default>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<object class="wxButton" name="m_button_Salir">
<label>Salir</label>
<default>0</default>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</resource>
第二个(要重复的对象作为数组):
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<resource xmlns="http://www.wxwindows.org/wxxrc" version="2.3.0.1">
<object class="wxPanel" name="MyPanel6">
<style>wxTAB_TRAVERSAL</style>
<size>500,300</size>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<option>0</option>
<flag>wxALL</flag>
<border>5</border>
<object class="wxButton" name="m_button5">
<label>FRAME2</label>
<default>0</default>
</object>
</object>
</object>
</object>
</resource>
如何在主 XRC 中制作一系列 XRC 面板?谢谢
最佳答案
首先,您的程序应该会死得很惨,因为您正在从 wxStaticBoxSizer
转换为 wxWindow
。我真的很想知道是什么让您觉得这样做是个好主意。
其次,在 XRC 中没有重复对象的规定,一般来说,如果您需要这样的东西,在代码中创建 3 个不同的面板,从相同的资源加载每个面板会更容易也更好。但你也可以使用 object_ref
如果您确实需要,可以使用 XRC 标记从其他地方引用现有对象。
关于c++ - 在另一个 xrc 中部署一个 xrc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15882830/
我是一名优秀的程序员,十分优秀!