Results 1 to 2 of 2

Thread: QPen has no effect

  1. #1
    Join Date
    Aug 2009
    Posts
    122
    Thanks
    74
    Qt products
    Qt4
    Platforms
    Windows

    Question QPen has no effect

    I'm drawing an image (see below) and it works in principle. However, for some reason two of the commands don't make any difference as if they weren't seen by the compiler. Does anyone have any ideas why?

    Qt Code:
    1. QPixmap map(100,100);
    2.  
    3. map.fill(Qt::white);
    4. QPainter p(&map);
    5. QPen pen;
    6. pen.setStyle(Qt::DashDotLine);//doesn't make a difference
    7. pen.setWidth(3); //doesn't make a difference
    8. p.setPen(QColor(0,0,0));
    9.  
    10. p.drawLine(50,50,100,100);
    11.  
    12. map.save("file.jpg", 0, 90);
    To copy to clipboard, switch view to plain text mode 
    Last edited by timmu; 3rd January 2013 at 11:37.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QPen has no effect

    Qt Code:
    1. QPixmap map(100,100);
    2.  
    3. map.fill(Qt::white);
    4. QPainter p(&map);
    5. QPen pen;
    6. pen = p.pen();
    7. pen.setStyle(Qt::DashDotLine);
    8. pen.setWidth(3);
    9. pen.setColor(QColor(0,0,0));
    10. p.setPen(pen);
    11. p.drawLine(50,50,100,100);
    12.  
    13. map.save("file.jpg", 0, 90);
    To copy to clipboard, switch view to plain text mode 
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. The following user says thank you to Santosh Reddy for this useful post:

    timmu (3rd January 2013)

Similar Threads

  1. QgraphicsSimpleTextItem, QPen outline
    By user14921 in forum Qt Programming
    Replies: 1
    Last Post: 9th October 2011, 16:07
  2. Strange behaviour with QPen
    By franco.amato in forum Qt Programming
    Replies: 4
    Last Post: 19th January 2010, 05:51
  3. Diff between QBrush and QPen
    By wagmare in forum Qt Programming
    Replies: 5
    Last Post: 16th February 2009, 14:47
  4. QPen color shift
    By Alberto in forum Qt Programming
    Replies: 0
    Last Post: 22nd October 2008, 11:35
  5. Problems with QPen
    By prosass in forum Newbie
    Replies: 3
    Last Post: 13th March 2007, 15:54

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.