Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Drawing text in QtOpenGLWidget
stevereine last edited by
I have the following code in the overridden PaintGL() function in my QtOpenGLWidget. It draw the ellipse, but not the text. What do I need to do to make the text visible? Just 2D text for now, that's all I need.
FYI - I am also using OpenGL drawing functions in this PaintGL() function, and they are all working fine.
QPainter painter(this); painter.begin(this); painter.setRenderHint(QPainter::TextAntialiasing); QColor fontcolor = QColor(1,0,0,1); QFont font = QFont("Arial",20); painter.setFont(font); painter.setPen(fontcolor); painter.drawText(200,500,"hello"); painter.setRenderHint(QPainter::Antialiasing, true); painter.setPen(QPen(Qt::black,3,Qt::DashDotLine, Qt::RoundCap)); painter.setBrush(QBrush(Qt::green, Qt::SolidPattern)); painter.drawEllipse(200, 80, 400, 240); painter.setFont(font); painter.setPen(fontcolor); painter.drawText(200,80,"hello, world"); painter.end();