Results 1 to 4 of 4

Thread: QPainter error using qwtPlot

  1. #1
    Join Date
    Feb 2012
    Posts
    17
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default QPainter error using qwtPlot

    Hello,
    I'm using qwtPlot and qwtPlotCurve to show diagrams that could be bigger than the video. I have cursors to move through the diagram. Y axis is the time axis and X axis is the amplitude of a signal. It is possible to control a zoom on the Y axis, increasing or reducing the size of the plot, specially on the Y axis.
    For example having a curve of 3000 samples I use a 5000 points plot to show it. Everything works well in this case.

    If I try to plot the same curve, with the same samples, on a bigger time scale, for example the curve of 3000 samples on a plot of 25000 points, i've got the errors:
    Qt Code:
    1. QPainter::begin Paint device returned engine == 0, type: 2
    2. QPainter::translate: Painter not active
    3. QPainter::save: Painter not active
    4. QPainter::setClipRct: Painter not active
    5. and so on.
    To copy to clipboard, switch view to plain text mode 
    I understood that could be a problem of QPixMap size not exactly defined, but I'm not able to find in the documentation in which way I can set it, because I don't use QPixmap explicitly but only through Qwt classes,
    Or maybe is something different that I don't know.

    This is the piece of my source code.
    Qt Code:
    1. QwtPlot * plot = new QwtPlot();
    2. QwtPlotCurve * plotCurve = new QwtPlotCurve();
    3.  
    4. plot->enableAxis(QwtPlot::xBottom, false);
    5. plot->enableAxis(QwtPlot::yLeft, false);
    6. plot->setCanvasBackground(Qt::white);
    7. plot->setFrameStyle(QFrame::NoFrame);
    8. plot->setCanvasLineWidth(1);
    9. plot->setAxisScale(QwtPlot::yLeft, samplesNumber, 0, 0);
    10. plot->axisScaleDraw(QwtPlot::yLeft);
    11. plot->setMaximumWidth(plotWidth);
    12. plot->setMaximumHeight(plotHeight);
    13.  
    14. plotCurve->setOrientation(Qt::Horizontal);
    15. plotCurve->setPaintAttribute(QwtPlotCurve::ClipPolygons, true);
    16. plotCurve->setSamples(amplitudeToShowValue[i], tValue);
    17. plotCurve->setPen(QColor(Qt::blue));
    18. plotCurve->setBrush(QBrush(Qt::blue, Qt::SolidPattern));
    19. plotCurve->setBaseline(0);
    20. plotCurve->attach(plot);
    To copy to clipboard, switch view to plain text mode 

    Thank you very much for any suggestion,
    carlo

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,313
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QPainter error using qwtPlot

    Quote Originally Posted by chinalski View Post
    I'm using qwtPlot and qwtPlotCurve to show diagrams that could be bigger than the video. I have cursors to move through the diagram. Y axis is the time axis and X axis is the amplitude of a signal. It is possible to control a zoom on the Y axis, increasing or reducing the size of the plot, specially on the Y axis.
    The solution you are trying to implement will let you run into performance, memory issues and more. Better don't waste any second more on this approach.

    If you want to implement zooming modify the scales ( using QwtPlot::setAxisScale ) instead.

    Uwe

  3. #3
    Join Date
    Feb 2012
    Posts
    17
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QPainter error using qwtPlot

    Thank you Uwe,
    I will study in deep what you suggest about zooming.

    And what about the error messages? The problem seems to me that is not related to zoom, but is about the total dimension of the plot: if the dimension is little everything is okay, if the dimension is bigger I get the errors (same number of samples, just different dimension of the plot).

    Searching on the web I found this page:
    http://www.developer.nokia.com/Commu...Known_Issue%29
    who say: "The solution is pretty simple and it's about defining a valid size for the QPixmap to paint. For instance defining it as QPixmap pix(100, 100) fix this issue."

    Since using qwtPlot I have no access to QPixMap, how can I try to solve this?
    Thanks

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,313
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QPainter error using qwtPlot

    You have to disable the backing store of the canvas ( QwtPlotCanvas::BackingStore ).

    Uwe

  5. The following user says thank you to Uwe for this useful post:

    chinalski (13th February 2013)

Similar Threads

  1. QwtPlot/Canvas and QPainter
    By carhun in forum Qwt
    Replies: 1
    Last Post: 20th August 2012, 13:14
  2. Replies: 0
    Last Post: 15th July 2011, 03:21
  3. QFrame error when subclassing QwtPlot
    By claudiacrb in forum Qwt
    Replies: 1
    Last Post: 30th April 2010, 08:04
  4. qwtplot run time error
    By hamid ghous in forum Qwt
    Replies: 2
    Last Post: 13th August 2009, 14:33
  5. ERROR:: QPainter: Internal error; no available GC
    By Krishnacins in forum Qt Programming
    Replies: 2
    Last Post: 8th March 2006, 06:05

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.