Solved 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"); qDebug()<<"process...."<<autocad->error()<<endl; }
whit the output:
process.... QProcess::ProcessError(FailedToStart)
reggards.
-
@Julian
Hi
I think it will work better with
http://doc.qt.io/qt-5/qdesktopservices.html#openUrlAlso , 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; autocad->setProgram(path+"Images/draw.dwg");; autocad->start();
process.... QProcess::ProcessError(FailedToStart)
-
Hi,
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.