0
這裏有一段代碼,把對parent
(wxPlane)中的所有元素:wxWidgets的:wxDatePickerCtrl擴大沒有明顯理由
parent->DestroyChildren();
wxBoxSizer* EntrySizer=new wxBoxSizer(wxVERTICAL);
EntryTitle = new wxStaticText(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, 0);
EntryTitle->Wrap(-1);
EntrySizer->Add(EntryTitle, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5);
wxBoxSizer* ValueSizer=new wxBoxSizer(wxHORIZONTAL);
Value_ = new wxStaticText(parent, wxID_ANY, wxT("Значение:"), wxDefaultPosition, wxDefaultSize, 0);
Value_->Wrap(-1);
ValueSizer->Add(Value_, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5);
wxDateTime t;t.ParseISODate(strvalue);
Value = new wxDatePickerCtrl(parent, wxID_ANY, t);
ValueSizer->Add(Value, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5);
EntrySizer->Add(ValueSizer, 1, wxEXPAND, 5);
EntrySizer->Add(0, 0,1, wxEXPAND, 5);
parent->SetSizer(EntrySizer);
parent->Layout();
Value->Bind(wxEVT_DATE_CHANGED,DateEntry::Edit,this);
Value->SetFocus();
它應該是這樣的(簡單的例子在wxFormBuilder):
但相反,它看起來像這樣:
我做錯了什麼?也許有旗子的東西?
這裏是一個最小的,完整的,並且可驗證示例代碼更簡單地示出了該問題:
#include <wx/wx.h>
#include <wx/app.h>
#include <wx/datectrl.h>
class cApp : public wxApp
{
public:
virtual bool OnInit();
};
class cFrame: public wxFrame
{
public:
cFrame(wxFrame *frame, const wxString& title)
: wxFrame(frame, -1, title,
wxPoint(-1,-1),wxSize(600,600))
{
wxBoxSizer* ValueSizer =
new wxBoxSizer(wxHORIZONTAL);
wxDatePickerCtrl * Value =
new wxDatePickerCtrl(this, wxID_ANY, wxDefaultDateTime);
ValueSizer->Add(Value, 0, wxALL, 5);
SetSizer(ValueSizer);
Layout();
}
};
IMPLEMENT_APP(cApp);
bool cApp::OnInit()
{
cFrame* frame =
new cFrame(0L, _("so41451250"));
frame->Show();
return true;
}
試試這個:ValueSizer-> Add(Value,0,wxEXPAND,5); – Igor
Nah,同樣的事情。 –