我懷疑有可能永遠不會有人用敏銳的眼力一個完美的替代品,爲工作和大量時間的激情投入到拖放,推動和拉動的小部件直到一切都如此。但是,如果您對能夠完成工作的workaday解決方案感到滿意,那麼我認爲wxWidgets sizers可以做出合理的工作。你是否熟悉這些?指定您要在小部件周圍留出多少空間,以及是否希望它們垂直或水平排列。現在,您只需將小部件添加到sizer中,然後sizer就會自動將它們安排在通常相當不錯的第一階段。
作爲一個簡單的例子,這裏是一個簡單的形式。
的代碼:
wxPanel * panel = new wxPanel(this,-1,wxPoint(-1,-1),wxSize(1000,1000));
wxSizerFlags szrflags(0);
szrflags.Border(wxALL,5);
wxBoxSizer * szrCRUDForm = new wxBoxSizer(wxVERTICAL);
wxFlexGridSizer * szr = new wxFlexGridSizer(2,1,1);
wxStaticText * field1text = new wxStaticText(panel,-1,"Entry Field #1");
wxTextCtrl * field1ctrl = new wxTextCtrl(panel,-1," ");
wxStaticText * field2text = new wxStaticText(panel,-1,"Second Entry Field");
wxTextCtrl * field2ctrl = new wxTextCtrl(panel,-1," ");
wxStaticText * field3text = new wxStaticText(panel,-1,
"A very big entry field\n"
"with a lot of description\n"
"Spread over several long lines of text");
wxTextCtrl * field3ctrl = new wxTextCtrl(panel,-1,"",wxPoint(-1,-1),wxSize(600,-1));
wxStaticText * field4text = new wxStaticText(panel,-1,"Yet another Field");
wxTextCtrl * field4ctrl = new wxTextCtrl(panel,-1," ");
szr->Add(field1text,szrflags);
szr->Add(field1ctrl,szrflags);
szr->Add(field2text,szrflags);
szr->Add(field2ctrl,szrflags);
szr->Add(field3text,szrflags);
szr->Add(field3ctrl,szrflags);
szr->Add(field4text,szrflags);
szr->Add(field4ctrl,szrflags);
wxBoxSizer * szrButtons = new wxBoxSizer(wxHORIZONTAL);
szrButtons->Add(new wxButton(panel,-1,L"CREATE"),szrflags);
szrButtons->Add(new wxButton(panel,-1,L"READ"),szrflags);
szrButtons->Add(new wxButton(panel,-1,L"UPDATE"),szrflags);
szrButtons->Add(new wxButton(panel,-1,L"DELETE"),szrflags);
szrCRUDForm->Add(szr);
szrCRUDForm->Add(szrButtons);
SetSizer(szrCRUDForm);
產生下列GUI,而不需要任何推動或拉動
這裏是介紹性的,而粗,教程http://neume.sourceforge.net/sizerdemo/
這裏是更復雜的東西http://zetcode.com/tutorials/wxwidgetstutorial/layoutmanagement/
我對sizers的工作並不十分了解,但我一定會研究你提供的代碼以及教程。謝謝你的幫助!我將此標記爲接受的答案。 –
理解並刪除:) –