Results 1 to 3 of 3

Thread: drawing an Arc using points

  1. #1
    Join Date
    Oct 2007
    Location
    Bangalore
    Posts
    27
    Qt products
    Qt4
    Platforms
    Windows

    Default drawing an Arc using points

    Hi,
    I want to draw an arc using points like p(x,y) and p1(x1,y1). Because i don't know the size of the rectangle to pass.But all drawArc functions in Qt will accept rectangle only.


    Regards,
    Sugandha

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: drawing an Arc using points

    An ARC cannot be defined by only two points. It's defined as a ellipse segment, so you must define the ellipse rectangle
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: drawing an Arc using points

    As pointed out above there is not enough information with just two points to specify an arc (presumably circular). Do you know the radius and two points, the centre and two points, or something else?

    If you know the centre and radius then the bounding rectangle becomes trivial:
    Qt Code:
    1. QRect bounds(centre.x()-radius, centre.y()-radius, 2*radius, 2*radius);
    To copy to clipboard, switch view to plain text mode 
    You can calculate the radius if only the centre is known (you could probably use the QPoint::manhattanLength() function to approximate). You only need calculate the angle to/between the points at the centre to have the remaining arguments for QPainter::drawArc().
    Last edited by ChrisW67; 11th July 2009 at 05:33.

Similar Threads

  1. Replies: 5
    Last Post: 21st March 2009, 10:10
  2. Problems with QString
    By cyberboy in forum Qt Programming
    Replies: 2
    Last Post: 13th October 2008, 09:18
  3. Replies: 1
    Last Post: 2nd October 2008, 08:29
  4. Drawing on QWidget - strech & resize
    By kemp in forum Qt Programming
    Replies: 5
    Last Post: 22nd January 2007, 15:39
  5. drawing points on canvas after a time period
    By quickNitin in forum Qt Programming
    Replies: 3
    Last Post: 12th May 2006, 15:12

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.