Results 1 to 2 of 2

Thread: QwtPlot/Canvas and QPainter

  1. #1
    Join Date
    Jun 2012
    Posts
    33
    Thanks
    6

    Default QwtPlot/Canvas and QPainter

    Hello.

    How can i get painter of QwtPlot, QwtPlotCanvas?

    I try to do like:
    QLine line(pos.x() - 5, canvas()->rect().bottom(), pos.x() - 5, canvas()->rect().top());
    1st method:
    QPainter *painter = new QPainter(const_cast<QwtPlotCanvas *>(canvas()));
    painter->save();
    painter->setPen(Qt::blue);
    painter->drawLine(line);
    painter->restore();

    2d method:
    QPainter *p = plot()->paintEngine()->painter();
    p->drawLine(line);

    3d method:
    // canvas()->paintEngine()->drawLines(&line, 1);
    QPaintEngine *pe = canvas()->paintEngine();
    pe->drawLines(&line, 1);

    There is no one work. Why?

    And how than I need to draw some line (not QwtPlotCurve) at QwtPlot?

  2. #2
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlot/Canvas and QPainter

    Just create a simple widget with trasnaprent background, stick it over the canvas and reimplement its paint() method.

Similar Threads

  1. How to set margin on one side of canvas plot (QwtPlot)
    By balvinder in forum Qt Programming
    Replies: 1
    Last Post: 13th February 2012, 16:15
  2. QwtPlot Canvas Size Hint?
    By umituzun84 in forum Qwt
    Replies: 8
    Last Post: 22nd September 2011, 16:21
  3. QwtPlot offset between Canvas and Scale
    By revellix in forum Qt Programming
    Replies: 2
    Last Post: 31st July 2011, 13:31
  4. Replies: 0
    Last Post: 4th May 2010, 09:45
  5. Replies: 1
    Last Post: 29th November 2008, 12:37

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.