Details
-
Bug
-
Resolution: Out of scope
-
P2: Important
-
None
-
5.5.0
-
None
-
I'm using Qt 5.5 on Windows 7 with GeForce GTX 460 graphics card.
Description
Hi,
I'm trying to figure out how to render text on a QOpenGLWidget. I read that QPainter could be used. I am able to render the text but the text looks corrupted (see attachment). Here is a small example code to reproduce the issue.
#include <QApplication> #include <QOpenglWidget> #include <QPainter> class MyOpenGLWidget : public QOpenGLWidget { public: MyOpenGLWidget(){} void initializeGL() { glClearColor(1.f, 1.f, 1.f, 1.f); } void resizeGL(int w, int h) { glViewport(0, 0, w, h); } void paintGL() { glClear(GL_COLOR_BUFFER_BIT); QPainter painter(this); painter.setPen(Qt::black); painter.setFont(QFont("Arial", 16)); painter.drawText(0, 0, width(), height(), Qt::AlignCenter, "Hello World!"); painter.end(); } }; int main(int argc, char **argv) { QApplication app(argc, argv); MyOpenGLWidget wnd; wnd.resize(400, 300); wnd.show(); return app.exec(); }
Is this a bug? I am doing something wrong? Or is there a better way to do this?
Thanks!