Results 1 to 2 of 2

Thread: Overloading Shape Paint change on scene zoom

  1. #1
    Join Date
    Jun 2010
    Location
    Italy
    Posts
    10
    Qt products
    Platforms
    Unix/X11 Windows

    Default Overloading Shape Paint change on scene zoom

    Hi ,

    Look at the following image and as you can see the two image are taken at a difference zooming level on the some entity.
    At certain zooming level the arc painted is smaller than the shape one.
    I use the some value for both the paint and shape method.
    The only difference is that for the shape I use the painterPath.arcTo and for the paint i use the painter.drawArc

    shape1.JPGshape2.JPG

    Qt Code:
    1. def arcRect(self):
    2. return QtCore.QRectF(self.xc,
    3. self.yc,
    4. self.h,
    5. self.h)
    6.  
    7.  
    8. def drawShape(self, painterPath):
    9. """
    10. called from shape method
    11. """
    12. r=self.h/2.0
    13. x=r*math.cos(self.sa)
    14. y=r*math.sin(self.sa)
    15. xc, yc=self.center
    16. x=xc+x
    17. y=(yc+y)*-1.0
    18. painterPath.moveTo(x, y)
    19. painterPath.arcTo(self.arcRect(),self.startAngle/16.0,self.spanAngle/16.0)
    20. #painterPath.moveTo(x, y)
    21. #painterPath.addRect(self.arcRect())
    22.  
    23. def drawGeometry(self, painter, option, widget):
    24. """
    25. called from the paint method
    26. """
    27. #Create Arc/Circle
    28.  
    29. painter.drawArc(self.xc,self.yc ,self.h ,self.h ,self.startAngle, self.spanAngle)
    To copy to clipboard, switch view to plain text mode 
    is it a qt Bug or I did something wrong ?
    Regards,
    Matteo

  2. #2
    Join Date
    Jun 2010
    Location
    Italy
    Posts
    10
    Qt products
    Platforms
    Unix/X11 Windows

    Smile Re: Overloading Shape Paint change on scene zoom

    Solved ..

    In may code the arc whose created with this code :
    Qt Code:
    1. painter.drawArc(self.xc,self.yc ,self.h ,self.h ,self.startAngle, self.spanAngle)
    To copy to clipboard, switch view to plain text mode 
    this accept only integer so the self.xc self.yc where double ..

    I change the code as follow:
    Qt Code:
    1. painter.drawArc(self.arcRect(),self.startAngle, self.spanAngle)
    To copy to clipboard, switch view to plain text mode 
    where self.arcRect() is a QRectF
    I hope this helps someone

    Regards,
    Matteo

Similar Threads

  1. Replies: 1
    Last Post: 30th July 2010, 07:50
  2. how to change shape of Qwidget??
    By anupamgee in forum Qt Programming
    Replies: 4
    Last Post: 29th June 2009, 09:54
  3. how to zoom out item in View/Scene
    By nileshsince1980 in forum Qt Programming
    Replies: 7
    Last Post: 28th December 2007, 10:24
  4. How to change shape fast
    By nileshsince1980 in forum Qt Programming
    Replies: 9
    Last Post: 18th October 2007, 05:49
  5. Question regarding how to paint after zoom.
    By JonathanForQT4 in forum Qt Programming
    Replies: 2
    Last Post: 26th January 2007, 15:34

Tags for this Thread

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.