The operating environment of this article:
操作系统:Windows 11 专业版
Visual Studio版本:Visual Studio 2022 Preview
Qt版本:Qt 5.14.2
1. Install the C++ compiler
In addition to Rust's own build tools, you'll need to set up a C++ compiler, Qt, and CMake.
On Windows, install Visual Studio (eg Visual Studio Community 2017 ). Make sure to enable the C++ application development component when installing Visual Studio.
2. Install Qt
【Qt domestic mirror website】
University of Science and Technology of China: http://mirrors.ustc.edu.cn/qtproject/Tsinghua
University: https://mirrors.tuna.tsinghua.edu.cn/qt/Beijing
Institute of Technology: http: //mirror.bit.edu.cn/qtproject/
China Internet Network Information Center: https://mirrors.cnnic.cn/qt/
Download Qt and install
It is recommended to disconnect from the network before installation, and the offline installation mode will be automatically activated after disconnecting the network.
【Custom installation directory】
【The installation is complete】
3. Set system environment variables
Right click on this computer -> properties -> -> advanced settings -> advanced -> environment variables
Edit the "Path" variable, the variable value is as follows:
D:\Common_software\IDE\Qt\Qt5.14.2\5.14.2\msvc2017_64\bin
D:\Common_software\IDE\Qt\Qt5.14.2\Tools\mingw730_64\bin
Remember to save the configuration.
4. Verify that Qt is installed correctly
命令行运行:cmake --version以验证cmake是否可用。
命令行运行:gcc -v以验证gcc是否可用。
If it is consistent with the picture below, the installation is no problem.
Close the cmd window, search for "Native" , find "x64 Native Tools Command Prompt for VS 2022 Preview", click to run
Note: Be sure to use the vs command prompt instead of the cmd command line that comes with the system, otherwise an error will be reported
Create a new folder named "tmp" on the D disk , and then enter the following commands respectively:
cd D:\tmp
mkdir build
cd build
qmake D:\Common_software\IDE\Qt\Qt5.14.2\Examples\Qt-5.14.2\widgets\dialogs\standarddialogs
nmake
release\standarddialogs.exe
5. Try to build the Rust-qt example
Run the following command using " vs command prompt "
Note: Be sure to use the vs command prompt instead of the cmd command line that comes with the system, otherwise an error will be reported
Create a new folder named "Text" in the "tmp" directory of the D disk , and then enter the following commands respectively:
cd D:\tmp\Text
git clone https://github.com/rust-qt/examples
cd examples
cargo run --bin basic_form