当前位置:网站首页>How to create a new project with VS+Qt
How to create a new project with VS+Qt
2022-08-09 16:17:00 【Nicolas0311】
The reason for this guideline is that two new people have recently entered the company.
One, just graduated and studied MFC.
One, I have many years of electrical experience and have taught myself C#.
But our company uses VC++ and Qt for projects.The pain of these two people is also very painful for me.In line with the principle of not giving up and not giving up, write some simple guidelines for them, and others who have encountered similar situations can refer to them.
Compilation environment: VS2012+Qt5.2.1 (off-topic: don't ask me why it's not the latest version, if you want to ask, ask the company's predecessors. In fact, these two versions are because the previous projects used some old external libraries,There is still a lot of code, and the writing method is relatively old. After a period of code sorting, it can be smoothly upgraded to VS and Qt that support newer).
1 Install VS2012 (self-query tutorial)
2 Install Qt5.2.1 (self-query tutorial)
3 Install the Qt-VS plugin
The plugin will add a wizard template for the Qt project to VS, which is used to create a Qt project in VS, and connect with the Qt compiler installed above, so that the Qt project can be compiled directly in VS
4 Creating a Qt Project in VS

5 Make some selections and settings based on the wizard template's predefined options
This step can basically do nothing, keep going next step, next step, next step.
6 compile and run
When compiling, you may encounter such a problem: the include file cannot be opened: "GLES2/gl2.h": No such file or directory
In VS, select the current project -> Properties -> C/C+±->General->Additional include directory->Header file directory, add **$(QTDIR)\include\QtANGLE**
At this time, a VS+Qt project program that has a form, can run, and has no function is completed.
7 Brief Description of Project File
demo1.ui is a visible-is-what-you-get UI interface design file (similar to MFC's demo1.rc, similar to C#'s Form1.cs).
demo1.qrc is the file used to add resources.
demo1.cpp, demo1.h is the implementation code of the Qt window class of the UI interface demo1.ui.
main.cpp is the entry point of the application, which calls the Qt window class demo1.
8 UI interface design through Qt Designer
After demo1.ui is opened with Qt Designer, design the interface according to your own needs.After the setting is complete, save it, go back to VS and press F7 to recompile demo1.ui.
The Qt plugin installed in VS will call the Qt compilerMoc, Uic recompile and generate the corresponding interface code, the generated files are as follows: moc_demo1.cpp, ui_demo1.h
9 Add external library files (no matter what project will inevitably call external files, whether it is customer or supplier)
There are generally two types of external library files.
- xxx.h header file, xxx.dll dynamic library file: This type can only call LoadLibrary(), GetAddress(), FreeLibrary() by dynamic call.
- xxx.h header file, xxx.dll dynamic library file, xxx.lib static library file: this type is more common, directly #include "xxx.h header file", #pragma comment(lib, "xxx.lib”) static library file, the xxx.dll dynamic library file can be placed in the exe.
The general new project creation process is now complete.
边栏推荐
猜你喜欢
随机推荐
常用类学习
Startup error: Caused by: org.apache.ibatis.binding.BindingException summary solution
VS2010:出现devenv.sln解决方案保存对话框
navicat for Oraclel链接oracle 报错oracle library is not loaded的解决办法
多线程学习
Mysql two engines comparison
正则化原理的简单分析(L1/L2正则化)
分析:通过哪种方法来建立股票量化交易数据库?
抢占量化交易基金产品先机,量化投资有发展空间?
redis从入门到精通
如何灵活运用量化交易接口的优势取长补短?
What do professional quantitative traders think about quantitative trading?
常见的数学物理方程
二维数组实现八皇后问题
如何通过通达信量化交易接口达到长期的收益?
C语言运算符优先级
MySql中什么是索引?常用的索引有哪些种类?索引在什么情况下会失效?
如何保证电脑硬盘格式化后数据不能被恢复?
Bean的生命周期
股票程序化交易如何理解自己的交易系统?









