安装Visual Studio 2017

下载并配置VS2017

  1. 进入Visual Studio官网,点击蓝色按钮“Download Visual Studio 2017”,按照流程登录并下载即可。
  2. 打开已下载好的Visual Studio Installer程序,对Visual Studio Community 2017进行配置。
  3. 选择工作负载->Windows(3)->使用C++的桌面开发后,点击右下角确认即可。

安装Qt插件

  1. 启动Visual Studio 2017后,看到如下界面:

    1

  2. 选择工具->扩展和更新->联机->Visual Studio Marketplace,并在右侧搜索处填入Qt:

    2

    安装即可,安装成功后,在VS2017窗口的菜单栏中会出现Qt VS Tools字段:

    3

安装Qt 5.14.2

安装配置Qt 5.14.2环境

  1. 进入下载地址,选择合适你系统版本的Qt安装包,在本文中我们选择qt-opensource-windows-x86-5.14.2.exe进行下载。

    你可以直接点击下方链接下载:

  1. 下载成功后,运行刚刚下载好的qt-opensource-windows-x86-5.14.2.exe,需要注册Qt账户并通过邮箱确认。

    4

    注册并成功登录后,一路下一步,直到选择组件部分。按如下配置选择:

    5

    点击下一步,等待安装完毕后启动Qt Creator即安装完成。

配置Visual Studio 2017中的Qt环境路径

  1. 打开Visual Studio 2017,选择上方Qt VS Tools->Qt Options,点击右侧add->...

    6

  2. 选择MSVC 2017的安装位置并确认:

    7

QWood项目编译与运行

获取QWood项目

  1. 打开cmd,跳转到合适的位置并运行

    1
    git clone https://github.com/thiagodnf/qwood.git

    (如果你的Windows没有git命令,建议百度Windows 10下安装git

  2. 运行完毕后,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

  1. 运行Qt Creator,点击左上角文件->打开文件或项目,选择qwood/QWood.pro文件

    8

  2. 配置项目

    9

  3. 编译与运行(右下角绿色三角)

    10

    在编译与运行时可能遇到如下问题及解决办法

    1. 函数无返回值

      样例

      11

      解决方法:

        双击红色报错部分,进入出错位置,并在如图中位置添加return nullptr;

      12

        注意:Qt Creator下方所有红色报错部分的相关文件都要更改。

    2. 缺少QIntValidator类型

        如果是.cpp文件出错,翻到代码顶部,若发现与cpp文件同名的.h文件,按住Ctrl并点击.h文件名即可跳转到相应的.h文件中,在.h文件头部添加:

      1
      #include <QtGui/QIntValidator>

        如果是.h文件出错,直接在头部添加上面的代码即可。

    成功运行:

    12

使用VS2017运行QWood

打开QWood

  1. 运行VS2017,点击上方Qt VS Tools->Open Qt Project File (.pro) ...,选择qwood/QWood.pro文件。

    14

    将项目编译方式选为:Release+x86,右侧红框内为项目结构。

  2. 编译并运行

    13

简单使用QWood

  1. 点击左上角Arquivo->Novo->AVL

  2. 在左上角的输入框内输入如下数字,每个数字按一次回车键或点击输入框右侧+ Inserir按钮添加数字。

    1
    1 3 5 7 9 2 4 6 8 10
  3. 运行效果

    15