本页内容

在桌面设备上运行

要为套件中选定的“运行设备”指定应用程序的运行设置,请转至“Projects ” > “Run Settings ”。

桌面设备的运行设置

工作目录

您可以指定要传递给可执行文件的命令行参数以及要使用的工作目录。工作目录默认设置为构建结果所在的目录。

选择“Deploy Settings ” > “Add Deploy Step ” > “CMake Install ”以添加安装选项。该选项将在不使用生成的构建系统或原生构建工具的情况下运行安装。Qt Creator 会自动将“Working directory ”字段的值作为安装目录添加到--install 签名中。

在终端中运行

对于控制台应用程序,请选择“Run in terminal ”。要在 Linux 和 macOS 上指定要使用的终端,请转至“Preferences ” > “Environment ” > “System ”。若要使用内部终端,请转至“Preferences ” > “Terminal ” > “Use internal terminal ”。

链接器库

在构建应用程序时,Qt Creator 会生成一个目录列表,链接器将在此处查找应用程序所链接的库。默认情况下,这些链接的库对Qt Creator 尝试运行的可执行文件是可见的。 通常,您仅应在该选项导致意外副作用,或者您使用部署步骤(例如make install )且希望确保部署后的应用程序在未使用Qt Creator 运行时也能找到这些库时,才应禁用此选项。

要禁用当前项目的库链接,请取消勾选“Add build library search path to PATH ”。要禁用所有项目的库链接,请转至“Preferences ” > “Build & Run ” > “General ”,然后取消勾选“Add linker library search paths to run environment ”。

调试已链接的框架

在 macOS 上,请选择“Use debug version of frameworks (DYLD_IMAGE_SUFFIX=_debug) ”以调试(例如,逐步执行)已链接的框架,例如 Qt 框架本身。调试应用程序代码时无需此选项。

过滤日志类别

要在“应用程序输出”中启用日志类别过滤(QLoggingCategory ),请选择Enable logging category filtering

以其他用户身份运行

在 Linux 和 macOS 上,请在“Run as user ”中选择“Default ”、“root ”或“Other ”,以不同的权限构建、部署和运行应用程序。

另请参阅 “配置项目以供运行”“指定自定义可执行文件以供运行”以及“指定运行环境”。

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.