QCustomPlot Discussion and Comments

Copy to clipboard or save in fileReturn to overview


with previous version of Qcustomplot i could copy a graph to the clipboard with the code below

void Graph2D::Copy_to_clipboard()
{
    // Set the clilpboard image
    QClipboard * clipboard = QApplication::clipboard();
    QPalette mypalette=this ->palette();
    mypalette.setColor(QPalette::Window,Qt::white);
    plot->setPalette(mypalette);
    QPixmap pixmap= QPixmap::grabWidget(this);
    clipboard->setPixmap(pixmap);
}

Graph2D class being a derivative of QWidget in which i use Qcustomplot and other control.

Now with latest version i get a grey rectangle.


What is the best way to copy a graph to clipboard ?
rgds,
Michael

Although I don't know why the new QCP version should make QPixmap::grabWidget stop working, I'd recommend using

QCustomPlot::toPixmap()

instead.

thanks for your quick answer...
I can indeed use this function but in the Qwidget i have the QcustomPlot and a TexEdit to display markers values.

I actually realized it is a QT5 related issue nothing to do with Qcustomplot, as even the TextEdit is not copied to clipboard.

rgds,
Michael