Win10下Qt 5.14.2+VS2017环境配置与编译运行qwood
安装Visual Studio 2017
下载并配置VS2017
- 进入Visual Studio官网,点击蓝色按钮“Download Visual Studio 2017”,按照流程登录并下载即可。
- 打开已下载好的
Visual Studio Installer
程序,对Visual Studio Community 2017
进行配置。 - 选择
工作负载
->Windows(3)
->使用C++的桌面开发
后,点击右下角确认即可。
安装Qt插件
启动Visual Studio 2017后,看到如下界面:
选择
工具
->扩展和更新
->联机
->Visual Studio Marketplace
,并在右侧搜索处填入Qt
:安装即可,安装成功后,在VS2017窗口的菜单栏中会出现
Qt VS Tools
字段:
安装Qt 5.14.2
安装配置Qt 5.14.2环境
进入下载地址,选择合适你系统版本的Qt安装包,在本文中我们选择
qt-opensource-windows-x86-5.14.2.exe
进行下载。你可以直接点击下方链接下载:
系统 | 链接 |
---|---|
Windows | qt-opensource-windows-x86-5.14.2.exe |
Mac OS X | qt-opensource-mac-x64-5.14.2.dmg |
Linux | qt-opensource-linux-x64-5.14.2.run |
下载成功后,运行刚刚下载好的
qt-opensource-windows-x86-5.14.2.exe
,需要注册Qt账户并通过邮箱确认。注册并成功登录后,一路下一步,直到
选择组件
部分。按如下配置选择:点击下一步,等待安装完毕后启动
Qt Creator
即安装完成。
配置Visual Studio 2017中的Qt环境路径
打开
Visual Studio 2017
,选择上方Qt VS Tools
->Qt Options
,点击右侧add
->...
选择
MSVC 2017
的安装位置并确认:
QWood项目编译与运行
获取QWood项目
打开
cmd
,跳转到合适的位置并运行1
git clone https://github.com/thiagodnf/qwood.git
(如果你的Windows没有git命令,建议百度Windows 10下安装git)
运行完毕后,cmd当前目录下会生成一个
qwood
文件夹,进入后有如下目录结构1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114.
|-- Makefile
|-- QWood.pro
|-- QWood.pro.user
|-- README.md
|-- configdialog.cpp
|-- configdialog.h
|-- configdialogpageestruturas.cpp
|-- configdialogpageestruturas.h
|-- configdialogpageestruturas.ui
|-- configdialogpages.cpp
|-- configdialogpages.h
|-- dist
| |-- Makefile
| `-- QWood
|-- entradas
| |-- cpp-home.txt
| |-- entrada2.txt
| |-- entrada3.txt
| |-- entrada_100.txt
| |-- entrada_100_inv.txt
| |-- entrada_livro.txt
| |-- main
| |-- main.cpp
| `-- problema.txt
|-- images
| |-- buscar.png
| |-- cascata.png
| |-- config.png
| |-- config_estruturas.png
| |-- delete.png
| |-- favicon.ico
| |-- favicon2.ico
| |-- fechar_tudo.png
| |-- inserir.png
| |-- lado_a_lado.png
| |-- limpar.png
| |-- logo.png
| |-- logo_qt.jpeg
| |-- logo_qt.png
| |-- logotipo_base.png
| |-- logotipo_base.xcf
| |-- logotipo_base1.png
| |-- logotipo_base2.png
| |-- sair.png
| |-- screenshot.png
| |-- update.png
| |-- zoomIn.png
| `-- zoomOut.png
|-- main.cpp
|-- mainwindow.cpp
|-- mainwindow.h
|-- moc_configdialog.cpp
|-- moc_configdialogpageestruturas.cpp
|-- moc_mainwindow.cpp
|-- moc_qbase.cpp
|-- moc_qconfigdialogpagesestruturas.cpp
|-- moc_qdialogabrir.cpp
|-- moc_qdialogarvoreb.cpp
|-- moc_qdialogarvorebplus.cpp
|-- moc_qdialoghash.cpp
|-- qavl.cpp
|-- qavl.h
|-- qb.cpp
|-- qb.h
|-- qbase.cpp
|-- qbase.h
|-- qbnodo.cpp
|-- qbnodo.h
|-- qbplus.cpp
|-- qbplus.h
|-- qbplusnodo.cpp
|-- qbplusnodo.h
|-- qbst.cpp
|-- qbst.h
|-- qbstnodo.cpp
|-- qbstnodo.h
|-- qdialogabrir.cpp
|-- qdialogabrir.h
|-- qdialogabrir.ui
|-- qdialogarvoreb.cpp
|-- qdialogarvoreb.h
|-- qdialogarvoreb.ui
|-- qdialogarvorebplus.cpp
|-- qdialogarvorebplus.h
|-- qdialogarvorebplus.ui
|-- qdialoghash.cpp
|-- qdialoghash.h
|-- qdialoghash.ui
|-- qopenhash.cpp
|-- qopenhash.h
|-- qopenhashnodo.cpp
|-- qopenhashnodo.h
|-- qopenhashtable.cpp
|-- qopenhashtable.h
|-- qrc_qwood.cpp
|-- qsplay.cpp
|-- qsplay.h
|-- qtrie.cpp
|-- qtrie.h
|-- qtrienodo.cpp
|-- qtrienodo.h
|-- qwood.qrc
|-- ui_configdialogpageestruturas.h
|-- ui_qconfigdialogpagesestruturas.h
|-- ui_qdialogabrir.h
|-- ui_qdialogarvoreb.h
|-- ui_qdialogarvorebplus.h
|-- ui_qdialoghash.h
|-- ui_qordemarvoreB.h
`-- uml
`-- QWood.xmi
4 directories, 107 files
使用Qt Creator运行QWood
运行
Qt Creator
,点击左上角文件
->打开文件或项目
,选择qwood/QWood.pro
文件配置项目
编译与运行(右下角绿色三角)
在编译与运行时可能遇到如下
问题及解决办法
:函数无返回值
样例
解决方法:
双击红色报错部分,进入出错位置,并在如图中位置添加
return nullptr;
注意:Qt Creator下方所有红色报错部分的相关文件都要更改。
缺少
QIntValidator
类型如果是
.cpp
文件出错,翻到代码顶部,若发现与cpp文件同名的.h
文件,按住Ctrl
并点击.h
文件名即可跳转到相应的.h
文件中,在.h
文件头部添加:1
如果是
.h
文件出错,直接在头部添加上面的代码即可。
成功运行:
使用VS2017运行QWood
打开QWood
运行VS2017,点击上方
Qt VS Tools
->Open Qt Project File (.pro) ...
,选择qwood/QWood.pro
文件。将项目编译方式选为:
Release
+x86
,右侧红框内为项目结构。编译并运行
简单使用QWood
点击左上角
Arquivo
->Novo
->AVL
在左上角的输入框内输入如下数字,每个数字按一次
回车键
或点击输入框右侧+ Inserir
按钮添加数字。1
1 3 5 7 9 2 4 6 8 10
运行效果