Results 1 to 13 of 13

Thread: Qt 5.7 QGraphicsObject paint issue

  1. #1
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android
    Thanks
    40

    Question Qt 5.7 QGraphicsObject paint issue

    Hi,

    I have QGraphicsObject derived items on a QGraphicsScene. Before Qt 5.7 everything was good. But when i compile project with 5.7 , painting of objects are getting out of view as seen on the attached image:
    Screenshot_1.jpg

    The main widget is split into 2 with a splitter. Left side is my view containing GraphicsObjects and right side is a tableview. As you could see, graphics objects overlaps table view and messes up all painting.

    i am just overriding paint method like that:

    Qt Code:
    1. void RealTimeChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
    2. {
    3. //painter->drawImage(boundingRect(),m_image.toImage());
    4. int width = m_rootData->w;
    5. int height= m_rootData->h;
    6. QRectF mrect= boundingRect().adjusted(width/15,height/10,-width/15,-height/10);
    7.  
    8. painter->fillRect(boundingRect(),QColor(Qt::white));
    9. painter->fillRect(boundingRect().adjusted(3,3,-3,-3),QColor(m_chrtdata->bgColor));
    10.  
    11. const QPointF points[7] = {
    12. QPointF(width/8, height/1.3),
    13. QPointF(width/4, height/2) ,
    14. QPointF(3*width/8, height/1.8),
    15. QPointF(width/2, height/2.5),
    16. QPointF(5*width/8, height/2.2) ,
    17. QPointF(3*width/4, height/4),
    18. QPointF(7*width/8, height/3)
    19. };
    20.  
    21. painter->setPen(QPen(Qt::red));
    22. painter->drawPolyline(points, 7);
    23.  
    24. painter->setPen(QColor(m_chrtdata->txtColor));
    25.  
    26. painter->drawLine(mrect.bottomLeft(),mrect.bottomRight());
    27. painter->drawLine(mrect.bottomLeft(),mrect.topLeft());
    28. painter->setPen(QPen(QColor(m_chrtdata->txtColor), 1, Qt::DotLine));
    29. painter->drawRect(mrect);
    30. painter->drawRect(QRectF(mrect.topLeft() ,
    31. QPointF(mrect.bottomLeft().x()+mrect.width()/2,
    32. mrect.bottomRight().y()) ));
    33.  
    34. painter->drawRect(QRectF(QPointF(mrect.topLeft().x(),
    35. mrect.topLeft().y()+mrect.height()/2) ,
    36. mrect.bottomRight() ));
    37. }
    To copy to clipboard, switch view to plain text mode 


    Any idea what changed on qt 5.7 and how to fix this ?

    Regards,
    Yigit

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Qt 5.7 QGraphicsObject paint issue

    Is the black thing is a graphics item and the left part with the dotted background is your graphicsview?

    The rendering looks like as if the black thing is a widget that is not part of the splitter but a sibling of the splitter and not in any layout.

    Cheers,
    _

  3. #3
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android
    Thanks
    40

    Default Re: Qt 5.7 QGraphicsObject paint issue

    Hi anda_skoa,

    Quote Originally Posted by anda_skoa View Post
    Is the black thing is a graphics item and the left part with the dotted background is your graphicsview?
    Yes, the dotted part is my view and that view is the left part of splitter. Right part of the splitter is the table view as seen in the screen capture.

    Quote Originally Posted by anda_skoa View Post
    The rendering looks like as if the black thing is a widget that is not part of the splitter but a sibling of the splitter and not in any layout.
    The black part is painted in the paint method of RealtimeChartItem which is a subclass of QGraphicsObject as shown above. And the objects are inserted into the scene by "scene->addItem(item)" as it should.

    Moreover there was nothing wrong with this code until Qt5.7

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Qt 5.7 QGraphicsObject paint issue

    Right, I just wanted to understand where each part came from.

    This sounds like a bug to me, i.e. the graphicview not clipping as it should.

    Can you reproduce that with a simple test program?
    Something like a splitter with a QGraphicsView and a label, with a simple line item in the scene, drawn at coordinates that make it reach "outside" the visible area?

    Cheers,
    _

  5. #5
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android
    Thanks
    40

    Default Re: Qt 5.7 QGraphicsObject paint issue

    Finally I could create a minimal example . The problem is that:
    I have a GraphicsItem which has a QGraphicsProxyWidget as a child. No problem when i add this item into scene

    But after adding this item, if i add a regular QGraphicsProxyWidget into scene( in sample code it contains a TableWidget) painting starts to mess up.. When you move the splitter in the example you will see GraphicsItem's paintings on TableWidget on top of each other...!

    if you comment that code:
    Qt Code:
    1. QTableWidget* tableInView = new QTableWidget;
    2. QGraphicsProxyWidget* testProxy = m_scene->addWidget(tableInView);
    3. testProxy->setPos(400,100);
    To copy to clipboard, switch view to plain text mode 

    everything starts to work correctly..
    By the way this situation only occurs on 5.7...
    Attached Files Attached Files

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Qt 5.7 QGraphicsObject paint issue

    You could check on https://bugreports.qt.io/secure/Dashboard.jspa if that has been reported already or report it if not.

    But do you really need some as complex as a table widget inside your graphics scene?

    Cheers,
    _

  7. #7
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android
    Thanks
    40

    Default Re: Qt 5.7 QGraphicsObject paint issue

    Yes i really need it. Moreover, the same error occurs after adding a simple pushbutton like that:

    Qt Code:
    1. QPushButton* butInView = new QPushButton;
    2. QGraphicsProxyWidget* testProxy = m_scene->addWidget(butInView);
    3. testProxy->setPos(400,100);
    To copy to clipboard, switch view to plain text mode 

    This cause QGraphicsItem with a child QGraphicsProxywidget to paint incorrectly.


    Added after 22 minutes:


    I reported the error:
    https://bugreports.qt.io/browse/QTBUG-55070
    Last edited by yagabey; 2nd August 2016 at 08:03.

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Qt 5.7 QGraphicsObject paint issue

    Generally a graphics proxy widget is alway borderline, widgets weren't designed to be rotated, scaled, etc.

    That's why such highly dynamic user interfaces that need these kind of transformations are usually built from the ground up, e.g. QtQuick (which in its first version was just QGraphicsItems in a scene).

    Cheers,
    _

  9. #9
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android
    Thanks
    40

    Default Re: Qt 5.7 QGraphicsObject paint issue

    Ok Anda, but there is no rotation or scale on these widgets. I simplified the test code a bit more. Now, there is no complex widgets like table or pushbutton. Only there are two proxywidgets using simple QLabel objects. And the problem still exists.

    ViewTest.zip

    I realised that when two objects are in the view the one containing child proxy shows that strange paint behaviour. But when the other proxy goes out of view, the painting problem disappears..

  10. #10
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Qt 5.7 QGraphicsObject paint issue

    Yes, sorry, misunderstanding.

    I wasn't implying that transformations of some sort would have caused the problem, that seems to originate elsewhere.

    What I wanted to say is that widgets were not designed to be in situations graphics items are, e.g. being zoomed or rotated, which is usually the use case for QGraphicsProxyWidget.

    Cheers,
    _

  11. The following user says thank you to anda_skoa for this useful post:

    yagabey (3rd August 2016)

  12. #11
    Join Date
    Aug 2016
    Posts
    1
    Thanked 2 Times in 1 Post

    Default Re: Qt 5.7 QGraphicsObject paint issue

    We had a similar bug. Try "setOpacity( 0.999 )" on QGraphicsItem and QGraphicsProxyWidget.

  13. The following 2 users say thank you to cordfield for this useful post:

    schollii (9th September 2016), yagabey (16th August 2016)

  14. #12
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android
    Thanks
    40

    Default Re: Qt 5.7 QGraphicsObject paint issue

    Yes, that worked...

  15. #13
    Join Date
    Apr 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    2

    Default Re: Qt 5.7 QGraphicsObject paint issue

    OMG, awesome, thanks for posting a workaround, at least gives us temporary relief and hopefully the Qt folks fix this eventually. Note that for us it was sufficient to set opacity to 1 - 0.00001 on all QGraphicsProxyWidget instances.

Similar Threads

  1. TableEditDelegate paint issue
    By anbu01 in forum Newbie
    Replies: 3
    Last Post: 17th December 2014, 15:32
  2. animating a QGraphicsObject
    By tommy22 in forum Qt Programming
    Replies: 4
    Last Post: 7th January 2013, 12:20
  3. QGraphicsObject Performance Issue
    By alizadeh91 in forum Qt Programming
    Replies: 0
    Last Post: 13th March 2012, 18:41
  4. How to make an QGraphicsObject animation?
    By luisvaldes88 in forum Qt Programming
    Replies: 2
    Last Post: 25th August 2011, 19:01
  5. protected QGraphicsObject
    By stefan in forum Qt Programming
    Replies: 6
    Last Post: 19th August 2011, 18:04

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.