简体   繁体   中英

Qt: How to save an image in asset from url?

Is it possible to save an image from an url in the assets folder?

void DataPacking::createAndSaveImage(QString argSavingFilePath,
        QByteArray argDataLoaded) {
    m_file = new QFile;
    m_file->setFileName(argSavingFilePath);
    m_file->open(QIODevice::WriteOnly);
    m_file->write(argDataLoaded);
    m_file->close();
    m_file->~QFile();
}

m_savingFilePath = QDir::homePath() + "app/native/assets/images/"
            + QString("multipleActive.png");

createAndSaveImage(m_savingFilePath, m_dataLoaded);

but when I try to use this image, I am getting the error below.

"Unable to get asset in (/apps/com.bluewave.LeasePlan.testDev_e_LeasePlan45b0f435/native/assets/): (/images/multipleActive.png)."

The assets directory (or more properly the app directory) is part of the protected area of the application sandbox that can not be changed. If you want to store data in the sandbox you should use the data directory.

See: https://developer.blackberry.com/native/documentation/cascades/device_platform/data_access/file_system.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM