Hi all,
I try to set the cosmetic pen for QGraphicsPolygonItem but if I use the opengl render it doesn't work as I expect.
Here the code:
scene.setSceneRect(-0.0005,-0.0005,0.001,0.001);
pen.
setColor(QColor(Qt
::red));
pen.setCosmetic(true);
polyItem->setPen(pen);
scene.addItem(polyItem);
ui->graphicsView->setBackgroundBrush(Qt::black);
ui
->graphicsView
->setRenderHint
(QPainter::Antialiasing);
ui->graphicsView->setScene(&scene);
scene.setSceneRect(-0.0005,-0.0005,0.001,0.001);
QPen pen;
pen.setColor(QColor(Qt::red));
pen.setCosmetic(true);
QPolygonF polyF;
polyF << QPointF(0.0002,0.0002)
<< QPointF(0.0003,0.0002)
<< QPointF(0.0003,0.0003)
<< QPointF(0.0002,0.0003);
QGraphicsPolygonItem* polyItem = new QGraphicsPolygonItem(polyF);
polyItem->setPen(pen);
scene.addItem(polyItem);
ui->graphicsView->setBackgroundBrush(Qt::black);
ui->graphicsView->setCacheMode(QGraphicsView::CacheBackground);
ui->graphicsView->setRenderHint(QPainter::Antialiasing);
ui->graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
ui->graphicsView->setScene(&scene);
To copy to clipboard, switch view to plain text mode
if I comment out the following code line it works fine.
ui->graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
To copy to clipboard, switch view to plain text mode
Thanks,
Giuseppe
Bookmarks