wxWidgets编程注意事项

1. 在类中定义对象:

{

    wxAuiManager m_mgr;

}

 

编译无法通过,输出类似错误:

demo_demo.o: In function `MyFrame::~MyFrame()':
demo.cpp:(.text+0x6491): undefined reference to `wxAuiManager::UnInit()'
demo.cpp:(.text+0x64a7): undefined reference to `wxAuiManager::~wxAuiManager()'
demo.cpp:(.text+0x64cb): undefined reference to `wxAuiManager::~wxAuiManager()'

原因在于makefile中没有包含库文件(aui),修改为:

g++ -o demo demo_demo.o   `wx-config --libs aui,core,base`

搞定!

 

 2. 确定类

window->IsKindOf(CLASSINFO(wxAuiNotebook))

这个类会用先调用:

DECLARE_DYNAMIC_CLASS

IMPLEMENT_DYNAMIC_CLASS

说明自己是什么类

 

 

3. 控件布局:

将界面中控件放入wxBoxSizer,所有控件在wxPanel *m_panel中:

wxBoxSizer sizer = new wxBoxSizer(wxVERTICAL);

.....

    m_panel->SetAutoLayout( true );
    m_panel->SetSizer( mainsizer );

sizer->SetSizeHints( this);

 

如果是wxSashLayoutWindow:

MyFrame::OnSize()

{

    wxLayoutAlgorithm layout;
    layout.LayoutFrame(this);

}

 

当button等空间size变化的时候,如果调用wxFlexGridSizer,变化时:

SetSizeHints()

FitInside()

在sample/scroll中。

 

OnSize对于控件有影响,比如:

MyFrame::OnSize()

MyPanel::OnSize()

 

类似于vtable的错误:

wellGrid_wellGrid.o: In function `WellGrid::WellGrid(wxWindow*, int, wxPoint const&, wxSize const&, long, wxString const&)':
wellGrid.cpp:(.text+0x3f2): undefined reference to `vtable for WellGrid'
wellGrid.cpp:(.text+0x3ff): undefined reference to `vtable for WellGrid'
wellGrid_wellGrid.o: In function `WellGrid::WellGrid(wxWindow*, int, wxPoint const&, wxSize const&, long, wxString const&)':
wellGrid.cpp:(.text+0x560): undefined reference to `vtable for WellGrid'
wellGrid.cpp:(.text+0x56d): undefined reference to `vtable for WellGrid'
wellGrid_wellGrid.o: In function `WellGrid::WellGrid()':
wellGrid.cpp:(.text+0x69c): undefined reference to `vtable for WellGrid'
有可能:

1.在*.h头文件中,声明了DECLARE_EVENT_TABLE(),在cpp中没有BEGIN_EVENT_TABLE()。。。

2.如果在*.h中,声明了虚函数,virtual void DrawRowLabels()。。。,没有在cpp中实现,也会出现此类错误。

 

 

wxString

1.

char* name = "TestName";

wxString::Format(_T("%s"), name);

执行的时候,会弹出warning,改为:

wxString::FromAscii(name);

it's OK.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值