windows 如何运行 Qt 应用程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/621262/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 12:07:31  来源:igfitidea点击:

How to run a Qt application?

c++windowsqt

提问by Kredns

I have been using Qt creator to make applications using the Qt libraries. I can run these applications by just clicking the play button, but I want to learn how to make applications run just by double clicking on a .exe. So how can I do this?

我一直在使用 Qt creator 来制作使用 Qt 库的应用程序。我只需单击播放按钮即可运行这些应用程序,但我想了解如何通过双击 .exe 来运行应用程序。那么我该怎么做呢?

回答by Arnold Spence

If you have built a 'release' version of your program, copy it and the following DLL's from qt\bin to a directory:

如果您已经构建了程序的“发布”版本,请将它和以下 DLL 从 qt\bin 复制到一个目录:

QtCore4.dll, QtGui4.dll and mingwm10.dll (if you are compiling with gcc and minGW).

QtCore4.dll、QtGui4.dll 和 mingwm10.dll(如果您使用 gcc 和 minGW 进行编译)。

If you are running a 'debug' build, you will need the debug versions of the Qt DLLs. They have the same name but with a 'd' at the end of the name.

如果您正在运行“调试”版本,您将需要 Qt DLL 的调试版本。它们具有相同的名称,但名称末尾带有“d”。

There may be other Qt DLLs you will have to copy depending on Qt modules you are using in your program.

根据您在程序中使用的 Qt 模块,您可能需要复制其他 Qt DLL。

You can find out more from this page (Qt docs website) Deploying Qt Applications

您可以从此页面(Qt 文档网站)部署 Qt 应用程序了解更多信息

回答by Judge Maygarden

I'm assuming you are running windows since you mention an .exe file extension. Look in the debug and/or release subdirectories of your project to find the produced binary. You can double-click on it to run the application. However, there are several DLL's that will be required. So, make sure they are in your PATHor copy them in the same directory. Dependency Walkeris useful for finding out what you need.

我假设您正在运行 Windows,因为您提到了 .exe 文件扩展名。查看项目的调试和/或发布子目录以查找生成的二进制文件。您可以双击它来运行应用程序。但是,有几个 DLL 是必需的。因此,请确保它们在您的PATH 中或将它们复制到同一目录中。Dependency Walker可用于找出您需要的内容。