Results 1 to 4 of 4

Thread: QPainterPath and moveTo problem

  1. #1
    Join Date
    May 2010
    Posts
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4

    Exclamation QPainterPath and moveTo problem

    Hi there.
    I want to draw bezier with QPainterPath.
    but moveTo() method draws one pixel line like attached image.

    my code here.

    Qt Code:
    1. QPoint s1, s2, e1, e2, cp11, cp12, cp21, cp22;
    2.  
    3. ...
    4.  
    5. path.moveTo(s2);
    6. path.lineTo(s1);
    7. path.cubicTo(cp11, cp12, e1);
    8. path.lineTo(e2);
    9.  
    10. path.moveTo(s2); /// this line draws one pixel line...
    11. path.cubicTo(cp21, cp22, e2);
    12.  
    13. pPainter_->setPen(Qt::NoPen);
    14. pPainter_->fillPath(path, QBrush(QColor(aFillColor.r, aFillColor.b, aFillColor.g)));
    To copy to clipboard, switch view to plain text mode 

    How can i remove one pixel line on the bezier?

    thanks
    Attached Images Attached Images
    Last edited by allting; 15th May 2010 at 12:07.

  2. #2
    Join Date
    May 2010
    Posts
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4

    Default Re: QPainterPath and moveTo problem

    I have to write a sample.

    Qt Code:
    1. #include <QApplication>
    2. #include <QGraphicsScene>
    3. #include <QGraphicsView>
    4. #include <QgraphicsItem>
    5. #include <QGraphicsTextItem>
    6. #include <QPainter>
    7.  
    8. class MyWidget : public QWidget
    9. {
    10. protected:
    11. void paintEvent ( QPaintEvent * event )
    12. {
    13. QPainter painter(this);
    14.  
    15. drawBeizer(painter, 0);
    16. drawBeizer(painter, 1);
    17. }
    18.  
    19. void drawBeizer(QPainter& painter, int i){
    20.  
    21. QPoint s1, s2, e1, e2, cp11, cp12, cp21, cp22;
    22.  
    23. if(0 == i){
    24. s1 = QPoint(384,341); cp11 = QPoint(336,230); cp12 = QPoint(376,116); e1 = QPoint(220,92) ;
    25. s2 = QPoint(400,330); cp21 = QPoint(352,230); cp22 = QPoint(392,116); e2 = QPoint(220,86) ;
    26. }else{
    27. s1 = QPoint(384,328); cp11 = QPoint(432,251); cp12 = QPoint(392,172); e1 = QPoint(564,149);
    28. s2 = QPoint(400,343); cp21 = QPoint(448,251); cp22 = QPoint(408,172); e2 = QPoint(564,155);
    29. }
    30.  
    31. path.moveTo(s2);
    32. path.lineTo(s1);
    33. path.cubicTo(cp11, cp12, e1);
    34. path.lineTo(e2);
    35.  
    36. path.moveTo(s2);
    37. path.cubicTo(cp21, cp22, e2);
    38.  
    39. painter.setPen(Qt::NoPen);
    40. painter.fillPath(path, QBrush(QColor(255, 90, 90)));
    41. }
    42.  
    43. };
    44.  
    45.  
    46. int main(int argc, char *argv[])
    47. {
    48. QApplication app(argc, argv);
    49.  
    50. MyWidget view;
    51. view.show();
    52.  
    53. return app.exec();
    54. }
    To copy to clipboard, switch view to plain text mode 

    it wroks fine.
    I still can not find the problem.

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

    TheIndependentAquarius (14th October 2013)

  4. #3
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: QPainterPath and moveTo problem

    Quote Originally Posted by allting View Post
    it wroks fine.
    Do you mean you still see the line or not?
    Because the example you posted works fine for me, I do not see straight lines, only two pink beziers

  5. #4
    Join Date
    May 2010
    Posts
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4

    Default Re: QPainterPath and moveTo problem

    Sample works fine.
    but, my real program still has problem.
    I can't find why it does not work.

Similar Threads

  1. QPainterPath and QPolygon
    By Muz in forum Qt Programming
    Replies: 0
    Last Post: 18th September 2009, 07:16
  2. Moveto perticular leine in QTextDocument
    By bismitapadhy in forum Qt Programming
    Replies: 6
    Last Post: 10th August 2009, 08:12
  3. Qpen, QBrush or QPainterpath problem
    By jano_alex_es in forum Newbie
    Replies: 2
    Last Post: 14th July 2009, 11:53
  4. QPainterPath outlining
    By viridis in forum Qt Programming
    Replies: 2
    Last Post: 14th March 2008, 19:32
  5. QPainterPath drawing problem
    By shad in forum Qt Programming
    Replies: 3
    Last Post: 17th January 2007, 13:30

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
  •  
Qt is a trademark of The Qt Company.