Hi, Text rendered with a QPainter in a QGLWidget looks awful.I have attached two screen shots, one with text rendered in a QWidget and one with text rendered in a QGLWidget.
I have also attached the code (Python + PySide) used to render the text.
How do I fix this? How do I get nice-looking text in a QGLWidget? Cheers, Johan
<<attachment: QWidget.png>>
<<attachment: QGLWidget.png>>
import sys from PySide.QtCore import * from PySide.QtGui import * from PySide.QtOpenGL import * class TestWidget(QWidget): def __init__(self): super(TestWidget, self).__init__() self.setWindowTitle('QWidget') def paintEvent(self, event): QWidget.paintEvent(self, event) p = QPainter(self) p.setFont(QFont('Arial', 8)) p.drawText(50, 20, '8pt: The quick brown fox jumps over the lazy dog') p.setFont(QFont('Arial', 10)) p.drawText(50, 40, '10pt: The quick brown fox jumps over the lazy dog') p.setFont(QFont('Arial', 12)) p.drawText(50, 62, '12pt: The quick brown fox jumps over the lazy dog') p.setFont(QFont('Arial', 14)) p.drawText(50, 86, '14pt: The quick brown fox jumps over the lazy dog') p.setFont(QFont('Arial', 16)) p.drawText(50, 112, '16pt: The quick brown fox jumps over the lazy dog') class TestGLWidget(QGLWidget): def __init__(self): super(TestGLWidget, self).__init__() self.setWindowTitle('QGLWidget') def paintEvent(self, event): QWidget.paintEvent(self, event) p = QPainter(self) p.setFont(QFont('Arial', 8)) p.drawText(50, 20, '8pt: The quick brown fox jumps over the lazy dog') p.setFont(QFont('Arial', 10)) p.drawText(50, 40, '10pt: The quick brown fox jumps over the lazy dog') p.setFont(QFont('Arial', 12)) p.drawText(50, 62, '12pt: The quick brown fox jumps over the lazy dog') p.setFont(QFont('Arial', 14)) p.drawText(50, 86, '14pt: The quick brown fox jumps over the lazy dog') p.setFont(QFont('Arial', 16)) p.drawText(50, 112, '16pt: The quick brown fox jumps over the lazy dog') if __name__ == '__main__': app = QApplication(sys.argv) w1 = TestWidget() w1.show() w2 = TestGLWidget() w2.show() app.exec_()
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest