Hello,
using QGraphicPathItems within a QGraphicsView with QGLWidget viewport I came across a strange memory consumption problem. It only happens when using a QGLWidget viewport and a DotLine or DashLine pen.
Here is a short code snipped:
MainWindow
::MainWindow(QWidget *parent
){
ui->setupUi(this);
pathItem
->setPen
(QPen(Qt
::black,
1.0, Qt
::DotLine));
view->scene()->addItem(pathItem);
double i = 1000000.0;
path.lineTo(i, -i);
path.lineTo(-i, i);
pathItem->setPath(path);
}
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
QGraphicsView * view = this->findChild<QGraphicsView*>();
view->setScene(new QGraphicsScene());
view->setViewport(new QGLWidget());
QGraphicsPathItem * pathItem = new QGraphicsPathItem();
pathItem->setPen(QPen(Qt::black, 1.0, Qt::DotLine));
view->scene()->addItem(pathItem);
double i = 1000000.0;
QPainterPath path;
path.lineTo(i, -i);
path.lineTo(-i, i);
pathItem->setPath(path);
}
To copy to clipboard, switch view to plain text mode
I tried several configurations with and without QGLWidget, with and without a solid line.
Here are the memory consumption results:
QGLWidget, SolidLine, i = 1000000.0 : 19,3 MB
QGLWidget, SolidLine, i = 5000000.0 : 19,3 MB
no QGLWidget, DotLine, i = 1000000.0 : 13,4 MB
no QGLWidget, DotLine, i = 5000000.0 : 13,4 MB
QGLWidget, DotLine, i = 1000000.0 : 395 MB
QGLWidget, DotLine, i = 5000000.0 : 1,73 GB
Any I ideas how to handle this problem or what I can do to still use dotted paths within a QGLWidget viewport?
Thanks
Lodorot
Bookmarks