QMimeData Custom Data Type | Recieving PDF Pages at DropEvent



  • Hello,

    How do i get the content of a MimeData with the following format:
    @
    application/x-qt-windows-mime;value="FileGroupDescriptorW"
    application/x-qt-windows-mime;value="FileContents"
    @

    I tried getting the Data with the two values (FileGroupDescriptorW or FileContents) and saving it in QArrayByte but i get 0 Byte
    @
    QByteArray input(mimeData->data("FileGroupDescriptorW"));
    setText(tr("%1 bytes").arg(input.size())) //Prints 0 Byte
    @



  • Hi,

    Why don't you print out the recognized mime types for the dropped object with QMimeData::formats() and try one of the values there?



  • bq. Why don’t you print out the recognized mime types for the dropped object with QMimeData::formats() and try one of the values there?

    That is exactly what i did and the formats are:
    @
    application/x-qt-windows-mime;value="FileGroupDescriptorW"
    application/x-qt-windows-mime;value="FileContents"
    @

    And i tried all the values, but am getting 0 Byte


  • Moderators

    as you have written you want the contents of 'application/x-qt-windows-mime;value="FileGroupDescriptorW"'. So why do you retrieve the data only asking for 'FileGroupDescriptorW' ?!
    Use:
    @
    QByteArray input( mimeData->data("application/x-qt-windows-mime;value="FileGroupDescriptorW") );
    @
    But note, Qt has a "bug":https://bugreports.qt.io/browse/QTBUG-17373 (which was fixed shortly in Qt 5.5) which prevents to get the 'FileContents' from the drop in case there were multiple files dragged. Of course this only affects Windows, since these are Windows specific mime-types.



  • Hi,

    Thanks for your efforts.

    I tried using the format to the data, but i still get 0 Byte
    @
    else {

        QStringList formatList = mimeData->formats();
        QString text;
        for (int i = 0; i < formatList.length() && i < 32; ++i) {
            QString formatStr = formatList.at(i);
            text += formatStr + QString(" : ") + QString::number(mimeData->data(formatStr).length()) + QString("\n");
        }
    
        setText(text);
    
    
        mouseMoveEvent(NULL);
    }
    

    @

    !https://dyp.im/fhsoOZrb8I(Result)!



  • This problem is solved.

    This Reason why i get 0 byte of Data is because the Datasource saves no Data in the Storage medium.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.