Results 1 to 2 of 2

Thread: incremental 2d plotter with QGraphicsView

  1. #1
    Join Date
    Aug 2009
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default incremental 2d plotter with QGraphicsView

    Hello.
    I'm using QT 4.5 on GNU/Linux.
    I'm trying to make a 2d plot Widget using QGraphicsView. I've done a few things in reference to this, always with a non-modificable QGraphicsItem, and everything goes well (it's really an excellet framework)
    But when i tried to make an real-time incremental plotter i get lost, because i don't know how to modify the content of the QGraphicsItem in a correct way, I mean, that the GraphicsItem update at acceptable time.
    I tried modifying the QPainterPath of the QGraphicsItem when a new point arrived, adding the point at the end.

    Qt Code:
    1. QPainterPath painterpath= item.path();
    2. painterpath.lineTo(newpoint);
    3. item.setPath(painterpath);
    To copy to clipboard, switch view to plain text mode 

    but that is really expensive, and i suppouse a bad way to do it.
    i took a look at QGraphicsItemAnimation but i couldn't see the way to do it, either.
    i've already seen the qwt project but i think it hasn't a QGraphicsView implementation.


    There are examples of something like that? How can i do it?


    thanks!
    Last edited by bingofuel; 24th August 2009 at 04:08.

  2. #2
    Join Date
    Aug 2009
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: incremental 2d plotter with QGraphicsView

    I think i have half of the problem solved.
    i connected the new point's arrival to the qGraphicsScene 's advance method and i've implemented a advance method in my QGraphicsPathItem according to an answer in stackoverflow, but now the problem, i think is here.

    Qt Code:
    1. p.lineTo(a);
    2. setPath(p);
    To copy to clipboard, switch view to plain text mode 

    when i set the path to the QGrapicsItem i think is copying all the path or drawing all the path everytime a new point is added. So is getting slower and slower.

    is there a way to avoid the re-drawing and only update the new part?
    maybe reimplementing the QGraphcisItem and the paintevent.
    is it viable this?

Similar Threads

  1. QGraphicsView performance
    By Halabund in forum Newbie
    Replies: 3
    Last Post: 17th April 2009, 10:12
  2. Replies: 0
    Last Post: 5th March 2009, 06:54
  3. Is it possible to change the cursor on a QGraphicsView?
    By draftpunk in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2008, 18:43
  4. QGraphicsView and embeded widgets
    By bunjee in forum Qt Programming
    Replies: 10
    Last Post: 12th October 2008, 07:43
  5. Speed, transparency, and drop issues with QGraphicsView
    By jefferai in forum Qt Programming
    Replies: 16
    Last Post: 30th June 2007, 16:14

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.