Results 1 to 3 of 3

Thread: Graphics Help

  1. #1
    Join Date
    Nov 2006
    Posts
    23
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Graphics Help

    I'm working on an app to chart some numerical data from an experiment and I want to implement a line drawing tool. This in itself is easy. Currently I've implemented a line drawing tool where you enter line drawing mode then click on the chart to start the line then move the mouse to drag the line to it's other end point then click to fix the end point and end that line draw. My question has to do with how best to handle the mouse move after the first click but before the last click. After a new line draw is started each move of the mouse results in a new line being drawn. But I only want to see one line on the screen. So currently I update the entire screen upon each mouse move event. This results in the effect that I desire. I click and drag the line to it's second point and click to fix the line and only see the one line in the process. The problem is that it's very inefficient to redraw the entire screen on each mouse move event when I only need to update the area where the old/new line is. I'm looking for pointers on how best to only update the required screen area. Thanks!!

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Graphics Help

    Are you using simple widget to draw ??
    You may have a look at QGraphicsScene or Qwt

  3. #3
    Join Date
    Nov 2006
    Posts
    23
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Graphics Help

    thanks aamer4yu,

    Yes, I'm drawing on a widget. One way that might work is to use QPixmap::grabWidget ( QWidget * widget, const QRect & rectangle ). On each mouse move event I might save the update area to a pixmap so that I can restore that part of the screen on the next mouse move event prior to drawing the new line. This would have the effect of updating/restoring only the affected screen area.
    Last edited by Thoosle; 23rd September 2008 at 14:49.

Similar Threads

  1. Learning 2D Graphics
    By ShaChris23 in forum Qt Programming
    Replies: 4
    Last Post: 23rd October 2007, 14:12
  2. QTreeWidget and Graphics scene
    By aamer4yu in forum Qt Programming
    Replies: 7
    Last Post: 21st December 2006, 17:24
  3. Adding Rectangular overlay on graphics view
    By forrestfsu in forum Qt Programming
    Replies: 10
    Last Post: 21st November 2006, 19:42
  4. QGLContext with multiple graphics cards
    By yuriy in forum Qt Programming
    Replies: 2
    Last Post: 11th September 2006, 15:35

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.