wxWidgets程式設計注意事項

2021-06-08 11:41:18 字數 2265 閱讀 1864

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.

程式設計注意事項

1.動態輸出表頭或資料 每次輸出之前,請先清空表頭以及資料再新增。2.一般資料都要分頁,請直接加上分頁 3.重複性資料的校驗 介面接收資料 1.介面接收資料,一般型別接受 例如 string 列印日誌,之後再轉換成自己想要的格式json等。需求評審 問題一 大面問題 1.是什麼?2.怎樣玩?業務流程...

VBA程式設計 注意事項

1 在自定義函式前加上 private 關鍵字進行宣告,該函式將不會出現在 excel的 貼上函式 對話方塊中,但仍然可以在公式中運用它們。如果是專門為其他的 vba過程開發的自定義函式,則應該使用 private 關鍵字進行宣告。2 通常,使用者自定義函式後,在 貼上函式 對話方塊中將會出現在 使...

IOCP程式設計注意事項

from 1 每個連線同時最好只有乙個待決的wsarecv。iocp不保證多個待決wsarecv情況下先投遞的wsarecv就一定會先得到完成通知。因此 多個待決wsarecv可能導致資料亂序,無謂增加 複雜性。2 投遞0長度緩衝區的wsarecv可以不占用非分頁記憶體,避免wsaenobufs錯誤...