Results 1 to 3 of 3

Thread: Qpainter draw line

  1. #1
    Join Date
    Mar 2012
    Location
    china
    Posts
    54
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Qpainter draw line

    QLinearGradient lg = QLinearGradient(QPointF(0,0),QPointF(0,1));
    lg.setCoordinateMode(QGradient::ObjectBoundingMode );
    lg.setSpread(QGradient::PadSpread);
    lg.setColorAt(0.0,QColor(0,0,0));
    lg.setColorAt(1.0,QColor(100,0,100));
    lg.setColorAt(0.5,QColor(0,255,0x7f));

    QBrush brush = QBrush(lg);

    QPainter painter(this);
    painter.setBrush(brush);
    QPen p;
    p.setBrush(brush);
    p.setWidth(2);
    painter.setPen(p);
    painter.drawLine(QPointF(400,400),QPointF(400,800) ); // @1
    painter.drawLine(QPointF(400,400),QPointF(450,410) );
    painter.drawLine(QPointF(400,400),QPointF(850,810) );
    painter.drawLine(QPointF(400,400),QPointF(800,400) ); // @2

    painter.drawRect(QRectF(0,100,300,100));

    //why the line @1 and @2 is not the same looks like the other????

    4.jpg

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qpainter draw line

    Because linear gradients have a direction so it matters whether something is drawn "along" or "across" a gradient.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2012
    Location
    china
    Posts
    54
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qpainter draw line

    I can't understant what is "across",how can I draw vertical line with the gradient?? thank you very much!
    Quote Originally Posted by wysota View Post
    Because linear gradients have a direction so it matters whether something is drawn "along" or "across" a gradient.

Similar Threads

  1. Draw line on image using QPainter
    By Qt Coder in forum Qt Programming
    Replies: 29
    Last Post: 11th August 2015, 12:09
  2. How does one draw a 'cut down' ellipse using QPainter
    By Eos Pengwern in forum Qt Programming
    Replies: 3
    Last Post: 24th July 2012, 01:01
  3. how to draw points with qpainter?
    By athulms in forum Newbie
    Replies: 4
    Last Post: 23rd August 2011, 08:10
  4. How to draw a line with tiled images with QPainter?
    By MadBear in forum Qt Programming
    Replies: 5
    Last Post: 25th July 2011, 06:36
  5. Draw Line
    By sagirahmed in forum Newbie
    Replies: 5
    Last Post: 18th October 2010, 07:49

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.