qnanopainter icon indicating copy to clipboard operation
qnanopainter copied to clipboard

Is it possible to integrate Qwt plot and qnanopainter ?

Open stephenlang84 opened this issue 2 years ago • 1 comments

Hi.

I'm using Qwt lib to render a graph, my app uses qml, but as you know Qwt bases on QWidget, so I used QQuickPaintedItem to paint the output of Qwt to my qml app, inspired are from https://github.com/carlos22/qwtquick2.

But this is a performance issue QTBUG-96205 of using QQuickPaintedItem to render a "QWidget's content".

Even though I enabled the QwtPlotOpenGLCanvas of Qwt but I found that this optimization only works for QWidget applications because QOpenGLWidget does not support the render() function with OpenGL. QwtPlotOpenGLCanvas is working well with a widget application, this is example app of Qwt. https://github.com/opencor/qwt/tree/master/examples/refreshtest.

So qnanopainter can help solving the QQuickPaintedItem's performance issue in this case. can't it ?

Actually I tried below solution, the frequency of calling this paint() or update the graph is 40 ms, but my implementation could not solve the CPU% that takes a lot of memory, I guess it is from creating the images.

void QwtQuickPainter::paint(QNanoPainter *painter)
{
    static int index = 0;
   QwtPlotOpenGLCanvas* plotCanvas = qobject_cast< QwtPlotOpenGLCanvas* >( m_qwtPlot->canvas() );
    QNanoImage nImage(plotCanvas->grab(QRect(0, 0, width(), height())).toImage(), QString::number(index));
    painter->drawImage(nImage, 0, 0, width(), height());
    index++;
}

Thanks for your advice !

stephenlang84 avatar Aug 01 '22 16:08 stephenlang84

I don't think you would get notable performance improvement with the above code. Generating images is probably the slow part and not blitting them with QNanoPainter. To get the benefits, Qwt itself would need to be ported QPainter -> QNanoPainter, which is probably quite a big task.

QUItCoding avatar Sep 24 '22 16:09 QUItCoding