VS2013+QT 5.4.1

Source: Internet
Author: User

QT applications can be developed with Qt Creator, or can be used with visual Studio. I've been using QT Creator, and I've always felt it was the best choice. But there are people who prefer Visual Studio, and I want to use Visual Studio to develop QT applications because of my job needs. Record the installation configuration process.

Download and install resources

The following resources are required:

    • Visual Studio 2013
    • QT SDK 5.4.1 (Qt-opensource-windows-x86-msvc2013_64-5.4.1.exe), which is the QT SDK, must be developed for QT applications.
    • Visual Studio Add-in 1.2.4 for Qt5 (Qt-vs-addin-1.2.4-opensource.exe), which is the official QT-provided plug-in for Visual Studio, functions as a sign-in to Visual Studio , a menu named QT5 is generated.

You can also download other QT versions or vs add-in, which have all the http://download.qt.io/archive/.

There is no order to install, whatever. It is worth noting that if your VS 2013 installation did not start once, and then installed QT vs add-in, and then start VS 2013, you will find no QT5 menu, but it doesn't matter, reboot VS 2013 to see the following image:

My blue circle is marked with the new QT5 menu. The QT version can then be configured.

Configuration

Open the QT5 menu, such as:

Choose QT Options to appear:

Click the icon's Add button to add a version. Such as:

In the Add New Qt version dialog box that pops up, fill in the QT version and select the QT path.

Special Note:When you add the Qt version in VS2013, you are looking for qmake in the bin directory, so you should choose something like "C:\Qt\Qt5.4.1\5.4\msvc2013_64" . If it is not a jiangzi path, it will report an error similar to the following:

With the correct QT Version configured, click the OK button and the effect is as follows:

Click the OK button and the configuration is complete. Now you can open the pro file via the QT5 menu.

Multiple QT versions can be configured in VS that do not conflict with each other.

VS in Qt Project import

The VS QT5 menu has an "open QT Project File (. Pro)" submenu that lets you open a QT program.

I created a QT project HELLOQT through QT Creator and then opened the pro file in VS, as shown in the following:

Here you can compile and run, press CTRL+F5.

In fact, when you open the Pro file in VS, Qt provides the VS add-in to automatically generate a vcxproj file (VC project file). Such as:

When you close the project, you are also prompted to save the solution (SLN file). After you save, you can open the QT project directly from the SLN next time.

Create a new QT project

I was just using QT creator to create a project and then import it through the VS QT5 menu, so that vs add-in automatically generated a project file (vcxproj) for vs.

In fact, we can also create a new Qt project directly from the VS File menu: New Project->qt5 PROJECTS->QT application.

When you create a new QT5 project, you can select a project type, such as QT application or QT Library. You can also select the modules that the project depends on. Give it a try.

Create a QT vs project with Qmake

Finally, there is a way to use the Qmake tool directly in the QT SDK to create a QT project for vs. From the QT command line tool in the Start menu, go to your project directory and execute the following commands: 5.4.1

    1. Qmake-project-t Vcapp-o Xx.pro (Note: If your project directory is the project name, you can remove the-o xx.pro these two parameters)
    2. Qmake

Then you can see the xx.vcxproj file.

Note that if your project directory is empty and there is no source file, then the above command is invalid.

I am more accustomed to QT creator to develop, if you are so, it can actually be developed in Qt Creator, after the development work is completed, then import into vs to see if there is any problem. If you choose the QT SDK when you choose the msvc2013 version, with VS2013, which is basically unlikely to be a problem.

VS2013+QT 5.4.1

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.