Results 1 to 2 of 2

Thread: line draw issue

  1. #1
    Join Date
    Sep 2012
    Posts
    11
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default line draw issue

    i have written simple application to draw a line between points using qpainter.but when i saw drawn line on widget it appears to be some broken line , instead of straight line between points. how to solved this issue.
    Qt Code:
    1. QPainter painter(this);
    2. painter.setRenderHint(QPainter::SmoothPixmapTransform,true);
    3. painter.fillRect(10 , 10, 300, 200, Qt::black);
    4. painter.setPen(QPen(Qt::green, 1));
    5. drawPath.moveTo(20,100);
    6. drawPath.lineTo(119,100);
    7. drawPath.moveTo(20,100);
    8. drawPath.lineTo(20,11);
    9. drawPath.moveTo(25,98);
    10. drawPath.lineTo(27,80);
    11. painter.drawPath(drawPath);
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

  2. #2
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: line draw issue

    Qt surely uses Bresenham algorithm to render the line : https://en.wikipedia.org/wiki/Bresen...line_algorithm
    Maybe increase the line width ? Maybe try this too : painter.setRenderHint(QPainter::Antialiasing, true);
    I see also QPainter::HighQualityAntialiasing in the doc, can be tried.

Similar Threads

  1. To draw a line
    By vinayaka in forum Qt Quick
    Replies: 1
    Last Post: 6th June 2011, 11:53
  2. Draw Line
    By sagirahmed in forum Newbie
    Replies: 5
    Last Post: 18th October 2010, 08:49
  3. Draw a line
    By Daan in forum KDE Forum
    Replies: 1
    Last Post: 27th August 2009, 18:29
  4. Draw Line
    By aloysiusjegan in forum Qwt
    Replies: 4
    Last Post: 12th February 2009, 12:02
  5. Best way to draw a Line
    By JimDaniel in forum Qt Programming
    Replies: 1
    Last Post: 19th January 2008, 10:57

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.