Qt-interest Archive, December 2007
Centering text within a groupbox
Message 1 in thread
Hi,
I tried this query on the PyQt mailing list and got no responses. I'm
resending it here, as I don't believe the problem is caused by the
binding, but rather by my misunderstanding of Qt...
I'm new to PyQt and Qt in general.
I want to make a QGroupBox containing a centered QLabel. The QLabel
needs to remain centered as the groupbox is resized.
It is easy to make a QLabel that stays centered:
#!/usr/bin/python2.4
import sys
import qt
a = qt.QApplication(sys.argv)
textlabel=qt.QLabel("textlabel",None)
textlabel.setAlignment(qt.QLabel.AlignCenter)
a.setMainWidget(textlabel)
textlabel.show()
a.exec_loop()
# end program
But I can't seem to get the same behavior inside the groupbox:
#!/usr/bin/python2.4
import sys
import qt
a = qt.QApplication(sys.argv)
gb = qt.QHGroupBox("gblabel",None)
textlabel=qt.QLabel("textlabel",gb)
textlabel.setAlignment(qt.QLabel.AlignCenter)
a.setMainWidget(gb)
gb.show()
a.exec_loop()
#end program
The label stays contered horizontally, but hugs the top of the groupbox.
What am I missing?
Regards,
Mark
markrages@gmail
--
[ signature omitted ]
Message 2 in thread
Looks like you need a layout inside the groupbox. A QVBoxLayout or a
QHBoxLayout will both do.
Bo.
On fredag den 14. December 2007, Mark Rages wrote:
> Hi,
>
> I tried this query on the PyQt mailing list and got no responses. I'm
> resending it here, as I don't believe the problem is caused by the
> binding, but rather by my misunderstanding of Qt...
>
> I'm new to PyQt and Qt in general.
>
> I want to make a QGroupBox containing a centered QLabel. The QLabel
> needs to remain centered as the groupbox is resized.
>
> It is easy to make a QLabel that stays centered:
> #!/usr/bin/python2.4
>
> import sys
> import qt
>
> a = qt.QApplication(sys.argv)
>
> textlabel=qt.QLabel("textlabel",None)
>
> textlabel.setAlignment(qt.QLabel.AlignCenter)
>
> a.setMainWidget(textlabel)
> textlabel.show()
> a.exec_loop()
> # end program
>
> But I can't seem to get the same behavior inside the groupbox:
>
>
> #!/usr/bin/python2.4
>
> import sys
> import qt
>
> a = qt.QApplication(sys.argv)
>
> gb = qt.QHGroupBox("gblabel",None)
>
> textlabel=qt.QLabel("textlabel",gb)
>
> textlabel.setAlignment(qt.QLabel.AlignCenter)
>
> a.setMainWidget(gb)
> gb.show()
> a.exec_loop()
> #end program
>
> The label stays contered horizontally, but hugs the top of the groupbox.
>
> What am I missing?
>
> Regards,
> Mark
> markrages@gmail
> --
> Mark Rages, Engineer
> Midwest Telecine LLC
> markrages@xxxxxxxxxxxxxxxxxxx
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. List archive and information:
> http://lists.trolltech.com/qt-interest/
--
[ signature omitted ]