CAD controls: Getting started with QT development using controls

Source: Internet
Author: User

1. Environment Construction: 3

1.1, installing Qt 3

1.2, installing the Microsoft Windows SDK Debug Package 6

2. Using Mxdraw controls in Qt 7

1.3, introducing controls 7

3. Open DWG file 11

1.4, add Open File button 11

1.5, using QT 13 in VS

    1. Environment Construction:

1.1. Install Qt

Website address: http://qt-project.org/, enter the official website, click [Download] to download page

As follows:

then click [Download], do not use its online installation, too slow, and then click [View all Downloads] can see from the download package, as follows: I choose the VC2010 development package here

In the following [other downloads], download the VS development Plugin as follows:

After downloading the file as follows:

Click "Qt-opensource-windows-x86-msvc2010_opengl-5.4.0.exe" to install the following:

Default I install in "C:\Qt\Qt5.4.0" directory

Select the Components page, choose all the installations, and then click [ next ]until the installation is complete:

Click "Qt-vs-addin-1.2.4-opensource.exe" to install the Qt development plugin in Visual Studio, follow the installation prompts, and after installation, the VS new project will have multiple QT options, as follows:

1.2. Install the Microsoft Windows SDK Debug Package

By default, qtcreator in a Windows environment, it is not possible to step through the program, prompting "debugger not set" and requiring the installation of a debug package for the Microsoft Windows SDK.

Microsoft Windows SDK:

http://www.microsoft.com/en-us/download/details.aspx?id=8442, as follows:

Click [Download] to download the ISO package

Download Grmsdk_en_dvd.iso

Open the ISO installation package and find the Dbg_x86.msi file installation in directory Setup\winsdkdebuggingtools. The default installation is generally selected. If it is a 64-bit system, install Setup\winsdkdebuggingtools_amd64\dbg_amd64.mis at the same time.

Open [Qt Creator]->[tool]->[Options]->[build and run]:: Build Kit (Kit), [Manual Settings]: Desktop, Debugger: automatic detection, so you can detect the installed debugger.

Then, restart Qt Creator, you can debug the project;

    1. using mxdraw controls in QT

Details on how to put the control in Qt and run

1.3. Introduction of controls

Run QT Creator, click [ file ]=>[ new file or project ..., and come out to the new Project window as follows:

Select "Qt Widgets Application" to create a new desktop project

To complete the new project, click "Mainwindow.ui" and go to the interface editor, such as:

On the interface, insert COM components, such as:

Run the Regmxdrawx.bat registration control under the control installation, only the controls are registered, and the MxDraw52 can be seen in the following interface, such as:

Double-click, drag the COM component to the interface, select MxDrawX52

Now you need to compile the run, the following connection error prompt, is because the project, did not add QT Axcontainer, Error prompts as follows:

Modify the project Properties file: Testqtmxdraw.pro, add qt + = Axcontainer, as follows

Save the Testqtmxdraw.pro file and run [ build ]=>[ execute qmake] compile Testqtmxdraw.pro file

Such as:

Then build all the projects, and the previous connection errors are eliminated.

Click to run after such as:

    1. Open DWG file

Shows how to open a function in a QT call control, open a DWG file

1.4. Add Open File button

Put a button on the interface and generate a button event,

Right click on the button, select [ go to slot ], add button click event

Click [ go to slot ]:

Add the following code:

void Mainwindow::on_pushbutton_clicked ()

{

Executes the control custom command function, the command ID is 2, the ID user can take any number of their own, it can be understood to be the command to execute a number.

Ui->axwidget->dynamiccall ("DoCommand (const qint32&)", 2);

}

Add to the control, and the command displays events such as:

In the function, add the following code to open the H-disk 1.DWG file:

void mainwindow::on_axwidget_implementcommandevent (int icommandid)

{

if (Icommandid = = 2)

{

Call the control open function to open the H: disk 1.dwg file.

Ui->axwidget->dynamiccall ("Opendwgfile (const qstring&)", "h:\\1.dwg");

}

}

1.5. Using QT in VS

Run VS, point [Qt5]=>[open Qt Project File (. Pro) ...] file that we just introduced to vs with Qt creator.

As follows:

After importing, it is easy to compile and run directly.

Here, congratulations, the use of QT development of our control has started ...

CAD controls: Getting started with QT development using controls

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.