Want to open an excel file .xlsm using resource .qrc



  • I have a qrc where I have an excel file to open.
    read function will just read excel file and display it on console.
    read(":/MyFile/resourcefile.pro");

    But, I want to open that excel file. I tried below code :
    p.start(":/excel/b1.xlsm");
    if (p.waitForStarted())
    {
    p.waitForFinished();
    qDebug() << p.readAllStandardOutput();
    }
    else
    qDebug() << "Failed to start";

    And I get "Failed to start".
    Any idea why can't i open the file using qrc.?


  • Moderators

    @nikit
    I assume p is of type QProcess?
    That won't work, since the process then would need to access binary data in your application memory.
    You should write the contents to a temporary file (e.g. use QTemporaryFile) or don't put it into your application's qrc in the first place.



  • Thank you for the reply.
    Yes its QProcess. Will it won't open a batch file also? Like
    QProcess p;
    p.start("/res/html/excel/run.bat");


  • Moderators

    @nikit said
    only from a path the launched process also has access to.
    qrc are in the caller application memory scope, so no access for another application. Easiest is you go the way over the filesystem.


Log in to reply
 

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