Results 1 to 20 of 23

Thread: how to prevent qgraphicsitem repaint while mouse move on it

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #18
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: how to prevent qgraphicsitem repaint while mouse move on it

    Quote Originally Posted by christina123y View Post
    Originally, my design to draw all points in an item in view of it will be easy to operate. and if i splitter all the points to several items, i don't know how to put these items together!
    I'm not sure what you mean by putting them together. You can have an item that represents the background of the graph (axis, etc.) and have multiple items that are child items of the graph item representing the contents of the graph (points).

    now,according to your direction, my thought is : splitter QVector<QPointF> vector which stores all the points to several segment, and then draw each segment's points on an item, but how can i put these items together appropriately just to compose integrate and correct graph, this means how i know where to put these small items, and how can i map each segment points to corresponding item's coordinate.
    For splitting space usually an algorithm called BSP (binary space partitioning) is used. It splits the plane into two sub-planes and then splits each sub-plane again and again until it reaches the stop condition. GraphicsView uses that algorithm internally to quickly find items based on their geometry. If you decided to represent each point in the graph as separate item, you could automatically use that built-in mechanism but if you want to have clusters, you have to implement BSP yourself.

    and how can i determin which items should be repainted
    Qt does that for you. It will only repaint items that need repainting (i.e. those that are visible and have been marked as dirty).


    A rule of a thumb is that if you have one item in the scene - you probably shouldn't be using QGraphicsView at all as it only adds to the complexity giving nothing in exchange. If you want to use Graphics View, have multiple items. Group them as you want using the parent-child relationship and squeeze as much from the architecture as possible.

    If you only want a single item with zooming and scrolling, you'll get much better results with a custom widget derived from QAbstractScrollArea.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. The following user says thank you to wysota for this useful post:

    christina123y (12th April 2009)

Similar Threads

  1. Replies: 9
    Last Post: 22nd June 2008, 22:26
  2. Replies: 4
    Last Post: 3rd March 2008, 22:15
  3. Mouse Move Event
    By merry in forum Newbie
    Replies: 5
    Last Post: 3rd June 2007, 06:26
  4. Move Rectangle on mouse Move
    By vermarajeev in forum Qt Programming
    Replies: 24
    Last Post: 14th May 2007, 05:34
  5. how to display full tree item name on mouse move ?
    By rajesh in forum Qt Programming
    Replies: 5
    Last Post: 15th November 2006, 08:41

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.