How to use QT to do solidworks two-time development

Source: Internet
Author: User
Tags api manual

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.