Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    QClipboard, pasting image on linux, how does it work

    General and Desktop
    1
    1
    727
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      G.o.D last edited by

      Hi there,

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

      [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();
      }
      [/code]

      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:

      [code]
      QVariant(QImage, QImage(QSize(0, 0) ) )
      pasted 0
      [/code]

      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?

      1 Reply Last reply Reply Quote 0
      • First post
        Last post