Results 1 to 15 of 15

Thread: Painting artefacts when using QPen with style other than SolidLine in QGraphicsView

  1. #1
    Join Date
    Jun 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question Painting artefacts when using QPen with style other than SolidLine in QGraphicsView

    Qt 4.6.0 (SDK for Windows with MinGW)
    Hello!
    Here is the minimum example:
    mainwindow.cpp :
    Qt Code:
    1. #include <QGraphicsView>
    2. #include "mainwindow.h"
    3. #include "myscene.h"
    4.  
    5. MainWindow::MainWindow(QWidget *parent)
    6. : QMainWindow(parent)
    7. {
    8. MyScene* s = new MyScene(this);
    9. s->setSceneRect(-1000,-1000,3000,3000);
    10. setCentralWidget(v);
    11. }
    To copy to clipboard, switch view to plain text mode 
    myscene.cpp:
    Qt Code:
    1. #include <QGraphicsEllipseItem>
    2. #include <QGraphicsSceneMouseEvent>
    3. #include "myscene.h"
    4.  
    5. MyScene::MyScene(QObject *parent) :
    6. {
    7. }
    8. void MyScene::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent * e )
    9. {
    10. QRectF circleRect(0,0,600,600);
    11. circleRect.moveCenter(e->scenePos());
    12. el->setPen(QPen(Qt::red, 4, Qt::DashLine));
    13. addItem(el);
    14. }
    To copy to clipboard, switch view to plain text mode 
    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:

    If I use Qt::SolidLine, everything is fine, but with Qt:ashLine and all other styles I see this painting artefact.
    Thanks in advance.

  2. #2
    Join Date
    Jun 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Painting artefacts when using QPen with style other than SolidLine in QGraphicsVi

    and setting QGraphicsView::FullViewportUpdate didn't help...

  3. #3
    Join Date
    Jun 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Painting artefacts when using QPen with style other than SolidLine in QGraphicsVi

    Please at least try it out, so I can know, is it seen on other platforms & compilers.

  4. #4
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: Painting artefacts when using QPen with style other than SolidLine in QGraphicsVi

    I dont see any artifacts in there. Can you point out with a green arrow what you do not want to have?
    It's nice to be important but it's more important to be nice.

  5. #5
    Join Date
    Jun 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Painting artefacts when using QPen with style other than SolidLine in QGraphicsVi

    The ellipse item is clipped.
    It should be a full circle.

  6. #6
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: Painting artefacts when using QPen with style other than SolidLine in QGraphicsVi

    What happens if you fill the ellipse with a brush. Does both the stroke and the fill get clipped?
    It's nice to be important but it's more important to be nice.

  7. #7
    Join Date
    Jun 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Painting artefacts when using QPen with style other than SolidLine in QGraphicsVi

    Everything is fine with the brush, but it didn't help to the pen ((

    http://i1.fastpic.ru/big/2010/0109/6...ca8d24f16c.jpg

  8. #8
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: Painting artefacts when using QPen with style other than SolidLine in QGraphicsVi

    Play around with different graphics subsystems, e.g. start your application with -graphicssystem raster or opengl and see whether there is a difference.
    It's nice to be important but it's more important to be nice.

  9. #9
    Join Date
    Jun 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Painting artefacts when using QPen with style other than SolidLine in QGraphicsVi

    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 ?

  10. #10
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: Painting artefacts when using QPen with style other than SolidLine in QGraphicsVi

    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.
    It's nice to be important but it's more important to be nice.

  11. #11
    Join Date
    Jun 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Painting artefacts when using QPen with style other than SolidLine in QGraphicsVi

    Here it is...
    Attached Files Attached Files

  12. #12
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: Painting artefacts when using QPen with style other than SolidLine in QGraphicsVi

    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.
    Attached Images Attached Images
    It's nice to be important but it's more important to be nice.

  13. #13
    Join Date
    Jun 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Painting artefacts when using QPen with style other than SolidLine in QGraphicsVi

    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!

  14. #14
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: Painting artefacts when using QPen with style other than SolidLine in QGraphicsVi

    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.
    It's nice to be important but it's more important to be nice.

  15. #15
    Join Date
    Jun 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Painting artefacts when using QPen with style other than SolidLine in QGraphicsVi

    Yahoo! they assigned P2 to my bugreport. Rather quick response and it's not a duplicate.
    http://bugreports.qt.nokia.com/browse/QTBUG-7253

Similar Threads

  1. Diff between QBrush and QPen
    By wagmare in forum Qt Programming
    Replies: 5
    Last Post: 16th February 2009, 14:47
  2. QPen color shift
    By Alberto in forum Qt Programming
    Replies: 0
    Last Post: 22nd October 2008, 11:35
  3. QGraphicsView : change selected rectangle style
    By kghose in forum Qt Programming
    Replies: 2
    Last Post: 28th July 2008, 18:12
  4. Slow painting in QGraphicsView
    By JonathanForQT4 in forum Qt Programming
    Replies: 12
    Last Post: 16th July 2007, 09:54
  5. Problems with QPen
    By prosass in forum Newbie
    Replies: 3
    Last Post: 13th March 2007, 15:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.