Results 1 to 2 of 2

Thread: Drawing a line on a QImage

  1. #1
    Join Date
    Mar 2015
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Drawing a line on a QImage

    I am trying to draw a line with penSize>=2 on a QImage . That is what I got:
    1bFS9uGL-e0.jpg

    Here is how I do it
    Qt Code:
    1. QPainter painter( getImage() );
    2. QPen pen( getLeftColor(),
    3. getPenSize(),
    4. Qt::SolidLine,
    5. Qt::SquareCap,
    6. Qt::MiterJoin );
    7. painter.setPen( pen );
    8. if ( _startPoint == _endPoint )
    9. painter.drawPoint( _endPoint );
    10. else
    11. painter.drawLine( _startPoint, _endPoint );
    12. painter.end();
    To copy to clipboard, switch view to plain text mode 

    How can I fix this graphical artifact?
    Last edited by Pritcher; 31st March 2015 at 16:34.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Drawing a line on a QImage

    Here is how I do it
    Oh really? There is nothing I can see in the fragment of code you have posted that will produce the effect shown in your screenshot. Your code draws either a line or a single point, not a series of jagged points.

Similar Threads

  1. drawing into QImage with OpenGL
    By produktdotestow in forum Qt Programming
    Replies: 2
    Last Post: 23rd July 2010, 13:10
  2. Drawing QImage inside QTextDocument
    By giusepped in forum Qt Programming
    Replies: 0
    Last Post: 13th April 2009, 07:52
  3. drawing on a QPixmap or QImage
    By gren15 in forum Newbie
    Replies: 15
    Last Post: 3rd March 2009, 17:48
  4. Almost reading QImage line by line, help me please.
    By newqtuser in forum Qt Programming
    Replies: 4
    Last Post: 18th July 2008, 14:22
  5. Drawing a QImage over QWidgets
    By Antrax in forum Qt Programming
    Replies: 4
    Last Post: 5th October 2006, 16:45

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.