[PyQt] QGrahics / textItemSize

Philippe Crave philippe.crave at gmail.com
Sat Feb 5 10:14:29 GMT 2011


Hello,

When I add to the Scene some rectangles and texts, rectangles are perfect,
but text are too big.

If I add a QGraphicsSimpleTextItem with a font_size of 40, it will display
bigger than the same text/font/size if I draw it in inkscape (or anywhere
else).
Seems that I have to scale with a ratio of 0.75 to get a correct size.

What am I doing wrong ?

here is my sample (I also attach a png with a text in Norasi with a size of
40):

 from PyQt4 import QtGui

import sys

app = QtGui.QApplication(sys.argv)

scene = QtGui.QGraphicsScene(0, 0, 400, 400)

scene.addSimpleText('HELLO 1', QtGui.QFont('Norasi', 40))

t = scene.addSimpleText('HELLO 2', QtGui.QFont('Norasi', 40))

t.setY(100)

t.scale(.75, .75)

view = QtGui.QGraphicsView(scene)

view.setRenderHint(QtGui.QPainter.Antialiasing)

view.setViewportUpdateMode(QtGui.QGraphicsView.BoundingRectViewportUpdate)

view.show()

sys.exit(app.exec_())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110205/6cbccf28/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: text2985.png
Type: image/png
Size: 1737 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110205/6cbccf28/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.py
Type: text/x-python
Size: 483 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110205/6cbccf28/attachment.py>


More information about the PyQt mailing list