Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to integrate Qwt plot and qnanopainter ? #66

Open
stephenlang84 opened this issue Aug 1, 2022 · 1 comment
Open

Is it possible to integrate Qwt plot and qnanopainter ? #66

stephenlang84 opened this issue Aug 1, 2022 · 1 comment

Comments

@stephenlang84
Copy link

stephenlang84 commented Aug 1, 2022

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 !

@QUItCoding
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants