python - How can I center a label in the center of a QWizardPage? -
i have label:
self.label = qtlabel(self)
that inside of vboxlayout.
that want set in center of qwizardpage, no matter size window becomes. managed centered horizontally with:
self.label.setalignment(qtcore.qt.aligncenter)
but cannot seem center vertically too. i've tried
self.label.setalignment(qtcore.qt.alignvcenter)
and:
self.label.setalignment(qtcore.qt.aligncenter | alignvcenter)
and couple of other things cannot remember @ moment (i'll edit if do). after reading this answer seemed problem had setting min , max size. tried that, setting minimumheight , maximumheight 200
. centered label doesn't adapt changes in window's height, width.
how can center label directly in middle of page?
add label in between 2 spacer items. vertical layout should laid out in parent widget takes full size of parent.
qspaceritem* verticalspacer1 = new qspaceritem(20, 40, qsizepolicy::minimum, qsizepolicy::expanding); label = new qlabel(form); label->setalignment(qt::aligncenter); qspaceritem* verticalspacer2 = new qspaceritem(20, 40, qsizepolicy::minimum, qsizepolicy::expanding); verticallayout->additem(verticalspacer1); verticallayout->addwidget(label); verticallayout->additem(verticalspacer2);
Comments
Post a Comment