Closed mohd-akram closed 6 years ago
I have removed wxST_NO_AUTORESIZE
style from constructor and label.layout().center()
should work as expected.
Label widget text alignment isn't implemented yet.
Almost there. Now the text doesn't get cutoff when it is changed, but its center position is the previously calculated one (which is a problem if you change the text to a longer or shorter one). I'm not sure how to trigger a relayout.
I want to create a label that fills the width of the window, but with the text centered. Currently, I have this:
Using
label.layout().justify()
fills the space, but causes the text to be left-aligned. Usinglabel.layout().center()
centers the element, but causes text to be cutoff when it is changed.I managed to get it to work with
static_cast<wxStaticText*>(label.native_handle())->SetWindowStyleFlag(wxALIGN_CENTRE_HORIZONTAL)
, but I also came across this issue where I had to set the text to an empty string first, so it would be nice to be able to set this in the constructor.