Hi,
I use a QGraphicsView, and I want to put some OpenGL on it, so I set a QGLWidget as the view port. Then I add some text in the scene. The problem is, if I set any rotation on the text, the text looks ugly (see attachement 1), as if there were no antialiasing. Everything looks fine if I set a no OpenGL view port (see attachement 2). So I would like to know what I am doing wrong... I add a small code example.
#include <QApplication>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGLWidget>
#include <QLabel>
#include <QGraphicsProxyWidget>
int main(int argc, char *argv[])
{
label
->setFont
(QFont("Arial",
24));
QGraphicsProxyWidget *proxy = scene.addWidget(label);
proxy->rotate(2);
view.
setRenderHints(QPainter::Antialiasing view.setViewport(viewport);
view.setGeometry(100, 100, 320, 60);
view.setScene(&scene);
view.show();
return app.exec();
}
#include <QApplication>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGLWidget>
#include <QLabel>
#include <QGraphicsProxyWidget>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel* label = new QLabel("Example Text");
label->setFont(QFont("Arial", 24));
QGraphicsScene scene;
QGraphicsProxyWidget *proxy = scene.addWidget(label);
proxy->rotate(2);
QGraphicsView view;
QGLWidget* viewport = new QGLWidget(QGLFormat(QGL::SampleBuffers));
view.setRenderHints(QPainter::Antialiasing
| QPainter::SmoothPixmapTransform
| QPainter::TextAntialiasing);
view.setViewport(viewport);
view.setGeometry(100, 100, 320, 60);
view.setScene(&scene);
view.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks