Results 1 to 2 of 2

Thread: Flicking overlayed widget on a QGraphicsView with QLWidget

  1. #1
    Join Date
    Sep 2009
    Posts
    140
    Thanks
    4
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Flicking overlayed widget on a QGraphicsView with QLWidget

    Hello,

    Glad to have found this forum and to use these so powerful Qt environment

    For my troubles working with QGraphicsView, I searched around several possibilities without success. So I post this thread and hope some help.

    I use a QGraphicsView to manage a lot (about 100000) heavy multi resolution image items (about 2Go each).
    So I derived QGraphicsItem to implement my own paint event according to the region refreshed and the level of details displayed. It works very well.

    In addition, I implemented a tool, attached to the mouse, that is used to see a reducted area under the mouse pointer, at a different lod. Unfortunalty, I cannot grab the result of the paint since I need the real data a better resolution.

    The idea I found was to create a floating QGraphicsView, which is populated at each mouse move with the usefull items. Since there ara copied into a new scene, the paint themself with the right region and the right lod. It works perfectly.
    I had also tried to manage a top level item but moving it for each mouseMove horribly slows down perfomance.

    Due to the heavy data to be displayed, I found that using a QGLWidget with double buffering activated as the viewport of my first QGraphicsview give me better perfomances, even when at high zoom factor.
    How great and so easy to use :
    Qt Code:
    1. setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
    To copy to clipboard, switch view to plain text mode 

    But my joy was slapped down when I noticed a strange flickering when my zoom cursor was displayed, at the upper left corner of the first view.

    Without OpenGL activated, the mouse cursor are always good, but perfomance are not satisfying.

    This is not only flickering because when I am editing a polygon on the QGraphicsView, whose shape it attached to the mouse, the current edited vertex is displayed on the corner of the screen, giving my polygon a strange distorsion!

    After investigation, it seems that the mouseMove event, in which I set the position of the cursor widget and vertex, is triggered with bad coordinates, whose values are under (100,100).
    This trouble happens for any QWidget overlayed over the QGraphicsView with QGLWidget set as viewport.

    I read on this forum that my case is not supported by Qt team, but does anyone has encoutered this problem, or implemented a cursor zoom functionnality in another way?

    Since I am using the version 4.5.0, am I right to hope better results with 4.6?

    Thanks by advance

    S.Cascio

  2. #2
    Join Date
    Sep 2009
    Posts
    140
    Thanks
    4
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Flicking overlayed widget on a QGraphicsView with QLWidget

    Since I have found afterwards that hard to read, I will simplify :

    Simply derived a QGraphicsView with some items in it.
    Add a member QLabel, never mind if empty, as child widget
    Overload the QGraphicsView::mouseMoveEvent to attach the child widget to the mouse position, with an offset of -size/2.
    Then, set a QGLWidget viewport of your QGraphicsView, with
    Qt Code:
    1. setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
    To copy to clipboard, switch view to plain text mode 

    When moving mouse, sometimes you can see the widget drawn on the upper left corner of the QGraphicsView, like a flickering or if it was drawn there before moving as kind of double buffering.

    But if you trace the mouse positions, you will see that the coordinates have changed to this weird position, so the drawing is good.
    This stuff does happen only with OpenGl activated.

    S.Cascio

Similar Threads

  1. How to Transparent QGraphicsView widget Background?
    By ashukla in forum Qt Programming
    Replies: 31
    Last Post: 6th March 2010, 11:35
  2. QDockWidget inside another widget in the center?
    By Antebios in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2010, 07:06
  3. Replies: 9
    Last Post: 22nd February 2008, 16:22
  4. Creating a widget on a QGraphicsView
    By maverick_pol in forum Qt Programming
    Replies: 4
    Last Post: 9th August 2007, 17:54
  5. widget qgraphicsview scaling
    By mistertoony in forum Qt Programming
    Replies: 10
    Last Post: 20th March 2007, 22:46

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.