Results 1 to 4 of 4

Thread: QGraphicsRectItem in FullScreen mode, when mouse dragging, blinking

  1. #1
    Join Date
    Jul 2008
    Location
    Munich
    Posts
    73
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default QGraphicsRectItem in FullScreen mode, when mouse dragging, blinking

    I have drawn QGraphicsItem in scene, and these QGraphicsItem have children(QGraphicsRectItem) above it as well.

    My program provides the mouse action to resize or move the child items. During mouse dragging, if I drag the right-side edge of the rect to left side, which makes the rect invalid (minus width), the paiting of the rect starts blinking. It paints only during mouse-move, which means, if I stop moving the mouse but pressing the mouse, it will not show up. But if I release mouse, it shows correctly. This problem only happends in FullScreen mode, in normal window mode, no such problem.

    I guess this comes from the zvalue of items. I set the parent zvalue: normal mode 2.0, Fullscreen mode 1.0. Child item is always 2.5.
    To my knowledge, this makes sure the child item will be above the parent item, then I can easily grasp it. But I don't know what happens for the paiting in fullscreen mode.

    Any one can give me a hint? Thanks.

  2. #2
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QGraphicsRectItem in FullScreen mode, when mouse dragging, blinking

    I guess (you didn't show any code) that when object resizes (boundingRect changes) you forgot to call QGraphicsItem::prepareGeometryChange!

  3. #3
    Join Date
    Jul 2008
    Location
    Munich
    Posts
    73
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsRectItem in FullScreen mode, when mouse dragging, blinking

    Quote Originally Posted by MarekR22 View Post
    I guess (you didn't show any code) that when object resizes (boundingRect changes) you forgot to call QGraphicsItem::prepareGeometryChange!
    I do call prepareGeometryChange() when I setRect() in child item (QGraphicsRectItem) inside mouseMoveEvent.

    I get some progress. I found, if in resizeEvent of QGraphicsView, code I has the blinking problem, code II doesn't. I am confused why this can cause such effect. resizeEvent is called only once when going to FullScreen mode, and never reached afterwards when I drag the edge of childItem. I can post the code of the resizeEvent:

    code I:

    Qt Code:
    1. void my_graphicsView::resizeEvent(QResizeEvent *event)
    2. {
    3. setWidth(event->size().width());
    4. setHeight(event->size().height());
    5.  
    6. fitInView(QRectF(0,0,width(),height()),Qt::KeepAspectRatioByExpanding);
    7. arrangeNodes();
    8.  
    9. m_scene->setSceneRect(0,0,width(),height());
    10. this->setSceneRect(0,0,width(),height());
    11.  
    12. update();
    13. }
    To copy to clipboard, switch view to plain text mode 

    code II:

    Qt Code:
    1. void my_graphicsView::resizeEvent(QResizeEvent *event)
    2. {
    3. setWidth(event->size().width());
    4. setHeight(event->size().height());
    5.  
    6. fitInView(QRectF(0,0,width(),height()),Qt::KeepAspectRatioByExpanding);
    7. arrangeNodes();
    8.  
    9. m_scene->update(0,0,width(),height());
    10. update();
    11. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by high_flyer; 30th March 2011 at 18:40. Reason: code tags

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,710
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsRectItem in FullScreen mode, when mouse dragging, blinking

    I am not sure what the logic of calling QGrphicsViewe::update() is, it will update the whole visible (maybe even the not visible part, I am not sure) scene as well.
    Why not just call updateScene()?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Hover on mouse over while dragging
    By mooreaa in forum Qt Programming
    Replies: 3
    Last Post: 6th February 2010, 10:31
  2. Hiding mac system menu in fullscreen mode
    By jupi32000 in forum Qt Programming
    Replies: 0
    Last Post: 18th November 2009, 19:32
  3. Custom mouse dragging an entire scene?
    By swbluto in forum Qt Programming
    Replies: 1
    Last Post: 26th October 2009, 15:46
  4. Dragging mouse selection in QTableWidget
    By yartov in forum Qt Programming
    Replies: 1
    Last Post: 12th April 2008, 15:03
  5. mode fullScreen
    By ederbs in forum Qt Programming
    Replies: 4
    Last Post: 20th January 2007, 00:42

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.