[PyQt] How to right align rich text (HTML) in a QLabel?
antwebid at gmail.com
Sat Apr 27 13:45:53 BST 2013
I asked the following question on StackOverflow but didn't get an answer.
Perhaps people here can help.
I have a simple task.
I want to right align richtext (HTML) in a PyQt QLabel. The QLabel works
fine until I resize the widget making it *smaller* than the text length. At
that point, the text to the right gets cut off. The QLabel works properly
with plain text.
In the PyQt example below, I list numbers one to ten. I want to always see
the number 'ten' even when I resize the widget. It works for plain text
(labelPT) but breaks for richtext (labelRT). How can I get the labelRT
version working properly?
Any help would be very welcome.
from PyQt4 import QtGui, QtCore
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
mw = QtGui.QWidget()
labelPT = QtGui.QLabel()
labelPT.setText('one two three four five six seven eight nine ten')
labelRT = QtGui.QLabel()
labelRT.setText('one two three four <b>five</b> six seven eight nine ten')
vbox = QtGui.QVBoxLayout()
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PyQt