为远程 Windows 设备进行开发
远程 Windows 设备是指Qt Creator 通过 SSH 连接并用作构建设备、运行设备或兼具两者功能的 Windows 计算机。源代码、构建目录和工具均保留在该计算机上,因此您可以从其他操作系统上进行 Windows 开发。
准备设备
在 Windows 计算机上安装 OpenSSH 服务器。这是 Windows 的可选功能,您可以在Settings >Optional features 中添加。启动OpenSSH SSH Server 服务,并允许其通过防火墙。
将您的公钥复制到%ProgramData%\ssh\administrators_authorized_keys ,或复制到要用于连接的用户主目录下的.ssh\authorized_keys 文件中。Qt Creator 不存储密码,因此基于密钥的身份验证可免去您每次连接时输入密码的麻烦。
添加设备
要添加远程 Windows 设备:
- 转至Preferences >Devices >Devices 。
- 选择“Add ” > “Remote Windows Device ”。
- 输入主机名、用户名以及用于连接的私钥文件。
- 选择“Test ”以检查连接。
要在“Qt Creator ”启动时连接到设备,请选择“Auto-connect on startup ”。
检测设备上的工具
在设备设置中选择“Run Auto-Detection Now ”以查找设备上的工具。“Qt Creator ”会检测 Microsoft Visual C++ 和 clang-cl 工具链、随附的调试器、Qt Online Installer 在C:\Qt 下安装的 Qt 版本和构建工具,并根据检测到的组合创建套件。
这些套件可在设备上进行构建。同时支持 CMake 和 qmake 项目。
运行与调试
应用程序在设备上以Qt Creator 所连接的用户桌面会话中运行,因此其窗口会显示在该计算机的屏幕上。当无人登录时,应用程序仍会运行,但不会显示桌面。
调试使用设备上的 CDB 调试器。要进行调试,请在设备设置中将CDB extension directory 设置为设备上已安装的Qt Creator 的lib 目录。
Qt Creator 通过 SSH 连接可访问应用程序的调试端口,这同样适用于性能分析以及 QML 预览。
另请参阅 《为远程 Linux 设备开发》、《添加 Docker 设备》和《管理开发套件》。
Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.