Radagast
7th January 2010, 10:56
Qt 4.6.0 (SDK for Windows with MinGW)
Hello!
Here is the minimum example:
mainwindow.cpp :
#include <QGraphicsView>
#include "mainwindow.h"
#include "myscene.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
MyScene* s = new MyScene(this);
s->setSceneRect(-1000,-1000,3000,3000);
QGraphicsView* v = new QGraphicsView(s);
setCentralWidget(v);
}
myscene.cpp:
#include <QGraphicsEllipseItem>
#include <QGraphicsSceneMouseEvent>
#include "myscene.h"
MyScene::MyScene(QObject *parent) :
QGraphicsScene(parent)
{
}
void MyScene::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent * e )
{
QRectF circleRect(0,0,600,600);
circleRect.moveCenter(e->scenePos());
QGraphicsEllipseItem* el = new QGraphicsEllipseItem(circleRect);
el->setPen(QPen(Qt::red, 4, Qt::DashLine));
addItem(el);
}
main.cpp, myscene.h and mainwindow.h are the default as generated by QtCreator (except that I added mouseDoubleClickEvent declaration to myscene.h).
When I double click in the corner of the view, the ellipse appears (Only part of it fits in the view and that's OK), and when I scroll the view to the right, I see this:
http://i1.fastpic.ru/big/2010/0107/75/995cfad917f5449aad250d75b20a8375.jpg
If I use Qt::SolidLine, everything is fine, but with Qt::DashLine and all other styles I see this painting artefact.
Thanks in advance.
Hello!
Here is the minimum example:
mainwindow.cpp :
#include <QGraphicsView>
#include "mainwindow.h"
#include "myscene.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
MyScene* s = new MyScene(this);
s->setSceneRect(-1000,-1000,3000,3000);
QGraphicsView* v = new QGraphicsView(s);
setCentralWidget(v);
}
myscene.cpp:
#include <QGraphicsEllipseItem>
#include <QGraphicsSceneMouseEvent>
#include "myscene.h"
MyScene::MyScene(QObject *parent) :
QGraphicsScene(parent)
{
}
void MyScene::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent * e )
{
QRectF circleRect(0,0,600,600);
circleRect.moveCenter(e->scenePos());
QGraphicsEllipseItem* el = new QGraphicsEllipseItem(circleRect);
el->setPen(QPen(Qt::red, 4, Qt::DashLine));
addItem(el);
}
main.cpp, myscene.h and mainwindow.h are the default as generated by QtCreator (except that I added mouseDoubleClickEvent declaration to myscene.h).
When I double click in the corner of the view, the ellipse appears (Only part of it fits in the view and that's OK), and when I scroll the view to the right, I see this:
http://i1.fastpic.ru/big/2010/0107/75/995cfad917f5449aad250d75b20a8375.jpg
If I use Qt::SolidLine, everything is fine, but with Qt::DashLine and all other styles I see this painting artefact.
Thanks in advance.