This problem has been bothering me for 2 years, the tutorials I found earlier are MFC, the ATL Import Wizard, or the way to invoke the control by importing a type library, I have never understood.
After learning ACTIVEQT recently and controlling Excel, Word, PowerPoint, and flash through ACTIVEQT, I finally got to the general understanding.
After a few hours of trying, finally successfully through the QT operation SolidWorks. Suggest you can go to Baidu related articles, key words ACTIVEQT
First of all, I would like to understand that VC is through the use of COM to operate SolidWorks, in this case, we just have to pass the QT COM operation method to control it.
I use Qt5.4, Solidworks2014.
In fact, there are two ways: 1. Use ClassID to get the COM object directly to manipulate SolidWorks. 2. Use the QT dumpcpp tool to export the H file and then control it with the pointer object.
The second approach is similar to the VC's development approach. But the exported file has 12mb,37w lines of code, the IDE is quite easy to crash, and compile errors, need to change a head of the file, but because it always crashes, I did not continue to try.
But the output header file can be viewed at least as an API manual, As for the output method: Copy the Sldworks.tlb file under the SolidWorks directory to any directory (I copied to my QT project directory), open the command line function of QT, go to this directory by CD, run Dumpcpp sldworks.tlb.
Let's take a look at the first method:
First add in the project file: qt+= Axcontainer, then run Qmake.
Add # include <ActiveQt/QAxObject> in CPP files
Then add the following code where you need to run:
Qaxobject *swapp=new qaxobject ("Sldworks.application", 0);
if (!swapp->isnull ())
{
Swapp->dynamiccall ("setvisible (BOOL)", true);
Swapp->dynamiccall ("OpenDoc (Qstring,int)", QString ("C:\\users\\512\\desktop\\a.sldprt"), 1);
}
Sldworks.application is a shorthand for COM, which can be obtained by searching the registry for named controls.
How to use QT to do solidworks two-time development