开发者

wxWidgets child sizer not expanding

I've got a very frustrating sizer problem.

I have two wxFlexGridSizers (and a few other things) inside a vertical wxBoxSizer, like so:

mMainSizer->Add(topsizer, wxSizerFlags(0).Expand());
mMainSizer->Add(1, lineheight);
mMainSizer->Add(mTypeLabel);
mMainSizer->Add(mTypeSizer, wxSizerFlags(0).Expand());
mMainSizer->Add(1, lineheight);

Each wxFlexGridSizer is filled using the same code:

sizer->Add(label, wxSizerFlags(1).Expand());
sizer->Add(fieldwidth, 1); // To separate label and data
sizer->Add(data, wxSizerFlags(0).Border(wxRIGHT, rborder).Right());开发者_JS百科

But the wxFlexGridSizers aren't being Expanded to the same width, as I intend. The lower one, with smaller labels, is always narrower than the upper one, leaving the data fields misaligned between them. Since they were both added with the Expand() flag, the narrower one should expand to the same width as the wider one, right?

(I've even tried adding the Right() flag to the lower one too, when adding it to the wxBoxSizer, but it did nothing, which really confused me.)

Can anyone save my sanity by pointing out where I'm going wrong?

EDIT: As far as I can tell, this is a wxWidgets bug. The Expand flag should tell items in a vertical sizer to expand themselves to their maximum width. If I'm wrong, someone please correct me.


As it turns out, the bug was mine. I thought I'd given the wxFlexGridSizers a growable column, with wxFlexGridSizer::AddGrowableCol, but that must have been in an earlier iteration of the code. Once I'd done that, they expanded just as I wanted them to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜