Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QClipboard/QMimeData problem with transparent images



  • Hello,

    i want to display an image that is stored within the clipboard using a QGraphicsScene object. If i use the the imageData() method i get an image that has lost its alpha channel. The normally transparent background is displayed as black. I am using the following code:

    @QPixmap image(mimeData->imageData().value<QPixmap>());
    if (!image.isNull()) {
    QGraphicsPixmapItem * imageItem = m_gfxScene.addPixmap(image);
    ui->m_gfxView->show();
    }@

    Is there a way to avoid this behavior?

    Another problem occured as i tried to get access to the "plain" clipboard data. If i try to call mimeData->data() i get a segmentation fault (SIGSEGV):

    @ QString mf = mimeData->formats().at(0); // contains an image format string
    QByteArray arr = mimeData->data(mf); // Segmentation fault
    // or
    QByteArray arr(mimeData->data(mf)); // Segmentation fault@

    I use the Qt SDK 1.1 RC and built the code using MinGW 4.4 (Qt 4.7.3 for Desktop).

    Thanks in advance!


Log in to reply