PDA

View Full Version : Painting artefacts when using QPen with style other than SolidLine in QGraphicsView



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.

Radagast
7th January 2010, 11:27
and setting QGraphicsView::FullViewportUpdate didn't help...

Radagast
8th January 2010, 08:22
Please at least try it out, so I can know, is it seen on other platforms & compilers.

axeljaeger
8th January 2010, 12:02
I dont see any artifacts in there. Can you point out with a green arrow what you do not want to have?

Radagast
8th January 2010, 15:15
The ellipse item is clipped.
It should be a full circle.

axeljaeger
9th January 2010, 11:05
What happens if you fill the ellipse with a brush. Does both the stroke and the fill get clipped?

Radagast
9th January 2010, 16:49
Everything is fine with the brush, but it didn't help to the pen ((

http://i1.fastpic.ru/big/2010/0109/6c/96056d1f5f70cd013bc4a0ca8d24f16c.jpg

axeljaeger
9th January 2010, 16:50
Play around with different graphics subsystems, e.g. start your application with -graphicssystem raster or opengl and see whether there is a difference.

Radagast
9th January 2010, 17:32
With OpenGL it just crashed at startup
here is the callstack
0 atiPPHSN C:\WINDOWS\system32\atioglxx.dll 0 0x691e9dab
1 ?? 0 0x00000010
2 ?? 0 0x00000260
3 ?? 0 0x00000000

I never used OpenGL earlier, seems that there are certain problems with it on my system or I just didn't tune smth.
anyway I'm not interested in OpenGL, I need raster engine.
Can't u please compile that code and tell about the result ?

axeljaeger
10th January 2010, 10:13
Can you post a zip-file containing a minimal, compileable example? From what I see, your first example is not complete because MyScene is missing. Then I can try out on my mac.

Radagast
10th January 2010, 12:13
Here it is...

axeljaeger
10th January 2010, 16:10
I get painting artifacts when scrolling, see Screenshot. This looks like a bugreport. You should search in the bug database whether something similar was already reported. If not, open a new issue and describe in detail how to reproduce this. I had to look into the sourcecode to see that I need to doubleclick. Also I first thought that everyone was fine until I scrolled around by accident.

Radagast
10th January 2010, 16:22
Seems like this is it
http://bugreports.qt.nokia.com/browse/QTBUG-6856
I wonder when they are going to release 4.6.1... don't want to download and build current branches <_<

Thanks!

axeljaeger
10th January 2010, 16:28
You should try the current branch to see whether your problem is really fixed. Maybe it is something else and can be included in 4.6.1 if not covered by that fix mentioned in the bugtracker.

Radagast
11th January 2010, 16:26
Yahoo! they assigned P2 to my bugreport. Rather quick response :) and it's not a duplicate.
http://bugreports.qt.nokia.com/browse/QTBUG-7253