Maximum QMimeData Size (Windows drag and drop and clipboard)

I have a problem with QMimeData using drag and drop and QClipboard. Scenario:

  • I have a medical image in SVG format (without a file, only a buffer) and various parameters for exporting the image to different file formats (for example, jpg, tiff, png, ...).
  • User can select resolution (in page format (e.g. DIN A7-DIN A3) and DPI (up to 600 DPI))
  • Drag and Drop / Clipboard is implemented with the QMimeData subclass class and the following MIME header entries:
    • "application / x-QT image"
    • "Filecontents"
    • "FileGroupDescriptorW"
    • "Filename"
    • "FileNameW"

This allows you to drag and drop files to the file system and to other applications (for example, Powerpoint). The implementation provides only the necessary data (for example, dragging a file system requires only a header / data 2-5 and dragging, for example, Powerpoint requires only a header / data 1). Intermediate files are not used.

The construction of the MIME data type (mimeData) is performed as follows:

void SCImageWidget::createDragAndDropData(QString mimeType)
{
    if(mimeType == "application/x-qt-image" && !mimeData->gotImage)
    {
        ...
        QImage img;
        this->renderSvgImage(img, ...)
        mimeData->setImageData(img);
        mimeData->gotImage = true;
        ...
    }
    else if(mimeType == "FileName" && !mimeData->gotFileName)
    {
        QString DDFileName = ... ;
        mimeData->setData("FileName", DDFileName.toLatin1());
        mimeData->gotFileName = true;
    }
    else if(mimeType == "FileNameW" && !mimeData->gotFileNameW)
    {
        QString DDFileName = ... ;

        mimeData->setData("FileNameW", QByteArray((const char*) (DDFileName.utf16()), DDFileName.size() * 2));
        mimeData->gotFileNameW = true;
    }
    else if(mimeType == "FileContents" && !mimeData->gotFileContent)
    {
        ...
        QByteArray data;
        QBuffer buffer(&data);
        buffer.open(QIODevice::WriteOnly);
        this->renderSvgImageToDevice(buffer, ...);
        buffer.close();
        mimeData->setData("FileContents", data);
        mimeData->gotFileContent = true;
        ...
    }
    else if(mimeType == "FileGroupDescriptorW" && !mimeData->gotFileDesc)
    {
        QString DDFileName = ...;
        FILEGROUPDESCRIPTOR desc;
        desc.cItems = 1;
        desc.fgd[0].dwFlags = FD_PROGRESSUI;
        wcscpy_s(desc.fgd[0].cFileName, DDFileName.toStdWString().c_str());
        mimeData->setData("FileGroupDescriptorW", QByteArray((const char*)&desc,
                          sizeof(FILEGROUPDESCRIPTOR)));
        mimeData->gotFileDesc = true;
    }

    return;
}

Problem:

  • Dragging large data records (> 11 MB) to the file system does not work (copying data / folder with an error) There is not enough free space, but it works through the clipboard (up to a certain point about 50 MB),
  • Image data> 200 DPI cannot be dragged into Powerpoint (even small compressed pngs) without errors. Using the clipboard even A3 / 600 DPI tiffs works.

: - Windows ( 1/16- ) ? . , - Qt.

: Dev. : Win 7 64/32GB RAM, Qt 5.3

SSCCE - .

+4

Source: https://habr.com/ru/post/1542061/


All Articles