Important: Please read the Qt Code of Conduct -

QClipboard, pasting image on linux, how does it work

  • Hi there,

    i am trying to paste an image in my Qt 5.0.2 application with this code:

    QClipboard *clipboard = QApplication::clipboard();
    const QMimeData *mimeData = clipboard->mimeData();

    if (mimeData->hasImage()) {
    qDebug() << mimeData->imageData();
    QImage image = qvariant_cast<QImage>(mimeData->imageData());
    qDebug() << "pasted " << image.width();

    So on linux running xfce desktop, i open the gimp, open a image, ctrl+a, ctrl+c, then go to my application and paste. What happens is: Gimp suddenly closes and debug output says:

    QVariant(QImage, QImage(QSize(0, 0) ) )
    pasted 0

    Also tried a screenshot tool instead of gimp, no image pasting, as the screenshot tool automatically closes when you say 'copy to clipboard', i can not say if it would crash too.

    What am i doing wrong?

Log in to reply