How to open a AutoCad file from Qt

  • Hello, I must open autocad from Qt. How can I open a program (like Autocad) from 0t application? for example, pressing a pushbutton autocad will open. What I want it's a link, something like an Hyperlink

    what do you think this:

     QProcess *autocad= new QProcess (this);
        autocad->start("C:\"Program Files\"Autodesk\"AutoCAD 2013\"acad.exe");

    whit the output:

    process.... QProcess::ProcessError(FailedToStart)


  • Qt Champions 2017

    I think it will work better with

    Also , in c++ you must ALWAYS have

    so it looks wrongly escaped

    autocad->start("C:\"Program Files\"Autodesk\"AutoCAD 2013\"acad.exe");

  • @Julian said in How to open a AutoCad file from Qt:

    autocad->start("C:"Program Files"Autodesk"AutoCAD 2013"acad.exe");

    This string will read as C:"Program Files"Autodesk"AutoCAD 2013"acad.exe so its not what you expect,

    as @mrjj already said, you have to use the correct escaping

  • autocad->start("C:/Program Files/Autodesk/AutoCAD 2013/acad.exe");

  • thanks that work! And I thought that open a autocad file it's the same as open autocad but not.

    I must open, for example, draw.dwg

     QString path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
        QProcess *autocad= new QProcess;

    process.... QProcess::ProcessError(FailedToStart)

  • Lifetime Qt Champion


    Because you are trying to start a file and not an application. If you would like to launch the application associated with a file type then use QDesktopService::openUrl.

Log in to reply

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