Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to open a AutoCad file from Qt
Forum Updated to NodeBB v4.3 + New Features

How to open a AutoCad file from Qt

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 5 Posters 2.6k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • JulianJ Offline
    JulianJ Offline
    Julian
    wrote on last edited by Julian
    #1

    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.

    mrjjM the_T 2 Replies Last reply
    0
    • JulianJ Julian

      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.

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Julian
      Hi
      I think it will work better with
      http://doc.qt.io/qt-5/qdesktopservices.html#openUrl

      Also , in c++ you must ALWAYS have
      \\

      so it looks wrongly escaped

      autocad->start("C:\"Program Files\"Autodesk\"AutoCAD 2013\"acad.exe");
      
      1 Reply Last reply
      5
      • JulianJ Julian

        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.

        the_T Offline
        the_T Offline
        the_
        wrote on last edited by
        #3

        @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

        -- No support in PM --

        1 Reply Last reply
        5
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

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

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          4
          • JulianJ Offline
            JulianJ Offline
            Julian
            wrote on last edited by Julian
            #5

            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)

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              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.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              5

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved