简体   繁体   English

运行按钮在 Qt Creator 中被禁用

[英]Run button is disabled in Qt Creator

This happens even on a freshly created, empty project.即使在新创建的空项目中也会发生这种情况。

The Run (and also Debug) buttons are disabled for the Qt5 configuration (they're enabled for the Qt4 configuration).运行(以及调试)按钮对于 Qt5 配置是禁用的(它们对于 Qt4 配置是启用的)。 The build button is not disabled, however, and it works - I can build the project, but I can't run it from Qt Creator.但是,构建按钮没有被禁用,它可以工作——我可以构建项目,但我无法从 Qt Creator 运行它。

They are disabled in the Build menu as well.它们在构建菜单中也被禁用。 Everything is enabled and works fine for the Qt4 configuration, however.然而,一切都已启用并且适用于 Qt4 配置。

It's a Qt/C++ project, on Windows 7 (32-bit).这是一个 Qt/C++ 项目,在 Windows 7(32 位)上。

在此处输入图像描述 在此处输入图像描述

Edit:编辑:

I found a couple of related questions - RUN button no enable in QtCreator for QML project and http://qt-project.org/forums/viewthread/15737 , but they have slightly different circumstances, and they don't show a clear solution.我发现了几个相关的问题 - RUN button no enable in QtCreator for QML project and http://qt-project.org/forums/viewthread/15737 ,但它们的情况略有不同,并且没有显示明确的解决方案. I'm posting them in case they help, though.不过,我会发布它们以防万一。

Edit 2:编辑 2:

I checked the run configuration for Qt5, as suggested by @Blueman and @Fabian, and the executable field is empty (and also disabled), even though the Build configuration correctly specifies the path.我按照@Blueman 和@Fabian 的建议检查了 Qt5 的运行配置,并且可执行字段为空(并且也被禁用),即使构建配置正确指定了路径。 Moreover, I get this error - "The.pro file untitled2.pro could not be parsed."此外,我收到此错误 - “The.pro 文件 untitled2.pro 无法解析。” Here's a screenshot:这是一个截图:

在此处输入图像描述

I am on Qt Creator 3.6 and it still happens.我在 Qt Creator 3.6 上,它仍然发生。 The run button is disabled after project is build.项目构建后运行按钮被禁用。 The only solution is to restart Qt Creator.唯一的解决方案是重新启动 Qt Creator。

I installed QtCreator 2.8.1 for test purposes and compile some project with Qt4.8.6 and Qt5.3我为了测试目的安装了 QtCreator 2.8.1 并用 Qt4.8.6 和 Qt5.3 编译了一些项目

Result is the same as your, there is a disabled run button for Qt5 configuration and a parse problem with .pro file.结果与您的相同,Qt5 配置的运行按钮已禁用, .pro文件存在解析问题。 Probably it's a bug.大概是个bug吧。

My suggestion is to change QtCreator to latest version (everything works fine for me).我的建议是将 QtCreator 更改为最新版本(对我来说一切正常)。

You don't have to reinstall whole qt environment, just install last QtCreator ( link ).您不必重新安装整个 qt 环境,只需安装最后一个 QtCreator( 链接)。 It will be a separate application so you can also use the old one if needed.它将是一个单独的应用程序,因此您也可以在需要时使用旧的应用程序。

Only problem is that the new installation (by default) use the same localization of settings as the old one.唯一的问题是新安装(默认情况下)使用与旧安装相同的本地化设置。 This may cause a problem.这可能会导致问题。

I solved this by changing the default path of settings for new installation.我通过更改新安装的默认设置路径解决了这个问题。 After installation (don't run !) create on desktop (or somewhere else) a shortcut for application, right click -> properties.安装后(不要运行!)在桌面(或其他地方)上创建应用程序的快捷方式,右键单击-> 属性。 Under the shortcut tab, you will see an area that says Target , add at end:在快捷方式选项卡下,您将看到一个区域,上面写着Target ,在最后添加:

-settingspath path -settingspath路径

where path is place where setting will be placed.其中path是放置设置的地方。

for me it look:对我来说它看起来:

C:\\Qt\\Tools\\qtcreator-2.8.1\\bin\\qtcreator.exe -settingspath C:\\Qt\\Tools\\qtcreator-2.8.1\\settings C:\\Qt\\Tools\\qtcreator-2.8.1\\bin\\qtcreator.exe -settingspath C:\\Qt\\Tools\\qtcreator-2.8.1\\settings

If new installation don't recognize both qt version and you don't know how to add it - just ask, I will add additional description.如果新安装不能识别这两个 qt 版本,并且您不知道如何添加它 - 只要问,我会添加额外的描述。

[EDIT] [编辑]

I found related question , the same problem, update of QtCreator was a solution.我发现了相关问题,同样的问题,更新 QtCreator 是一个解决方案。

Open the projects .pro file and make some arbitrary modification and save the changes.打开项目 .pro 文件并进行一些任意修改并保存更改。 This will cause the .pro file to be re-parsed and for whatever reason will re-enable the run button.这将导致 .pro 文件被重新解析,并且无论出于何种原因都会重新启用运行按钮。

I haven't seen this in a good couple of months but it used to plague me!我已经好几个月没有看到这个了,但它曾经困扰着我! Personally I would remove a random line from the .pro file, save it, re-add the line I removed the save it again.我个人会从 .pro 文件中随机删除一行,保存它,重新添加我删除的行并再次保存。 Worked every time!每次都工作!

I had same problem but in a bit different situation.我遇到了同样的问题,但情况略有不同。 However solution might be suitable for more people.然而,解决方案可能适合更多人。

When in a debug edition of the project (this is important) I added a header file using Right Mouse Button on a project >> Add Existing File, I could not run the project.在项目的调试版本中(这很重要)我在项目上使用鼠标右键添加了一个头文件 >> 添加现有文件,我无法运行该项目。 I could clean, (re)build but not run.我可以清理,(重新)构建但不能运行。 The file was correctly added to .pro file.该文件已正确添加到 .pro 文件中。 It did not matter whether I included the file anywhere in code (using #include instrution) or not.我是否将文件包含在代码中的任何位置(使用 #include 指令)都没有关系。

If instead I clicked Right Mouse Button >> Add New ... >> C++ >> C++ Header File and pasted the code there, then I was able to run the project (obviously also clean, (re)build, run).相反,如果我单击鼠标右键 >> 添加新... >> C++ >> C++ 头文件并将代码粘贴到那里,那么我就能够运行该项目(显然也是干净的,(重新)构建,运行)。

Solution is: change build edition to release, rebuild, and then switch to back debug.解决方法是:将build版本改为release,rebuild,然后切换回debug。

Here is how I found solution to that.这是我找到解决方案的方法。 It happened to me at first on Windows 7 with Qt Creator 3.3.1 Opensource version.起初我在使用 Qt Creator 3.3.1 开源版本的 Windows 7 上发生了这种情况。 On Windows 7 the build bar always finished at 100% and in green what misled me.在 Windows 7 上,构建栏总是以 100% 完成,并且是绿色的,这误导了我。 I opened the same project under Kubuntu 14.10.我在 Kubuntu 14.10 下打开了同一个项目。 On Kubuntu Qt Creator showed me build bar in orange/red and displayed [4 Compile Output] as follows:在 Kubuntu Qt Creator 上向我展示了橙色/红色的构建栏,并显示 [4 编译输出] 如下:

12:07:12: Running steps for project Threads02... 12:07:12: Could not create directory "/home/oskar/share/build-Threads02-Desktop_Qt_5_4_1_GCC_32bit-Debug" Error while building/deploying project Threads02 (kit: Desktop Qt 5.4.1 GCC 32bit) When executing step "qmake" 12:07:12: Elapsed time: 00:00. 12:07:12:运行项目 Threads02 的步骤... 12:07:12:无法创建目录“/home/oskar/share/build-Threads02-Desktop_Qt_5_4_1_GCC_32bit-Debug”构建/部署项目 Threads02 时出错(套件:桌面 Qt 5.4.1 GCC 32 位)执行步骤“qmake”时 12:07:12:经过时间:00:00。

It is not so indicative in itself.它本身并不是那么具有指示性。 But the fact that very same project showed build errors on a different platform made me go back to Windows 7 and take a look what is there under [4 Compile Output].但是,同一个项目在不同平台上显示构建错误这一事实让我回到 Windows 7 并查看 [4 Compile Output] 下的内容。 And there were 2 things that I noticed:我注意到两件事:

... Could Not Find C:\\Users\\me\\Documents\\build-Threads02-Desktop_Qt_5_4_1_MinGW_32bit-Debug\\debug\\main.o ... Could Not Find C:\\Users\\me\\Documents\\build-Threads02-Desktop_Qt_5_4_1_MinGW_32bit-Debug\\release\\main.o ... ... 找不到 C:\\Users\\me\\Documents\\build-Threads02-Desktop_Qt_5_4_1_MinGW_32bit-Debug\\debug\\main.o ... 找不到 C:\\Users\\me\\Documents\\build-Threads02-Desktop_Qt_5_4_1_MinGW_32bit-Debug \\release\\main.o ...

The "release" word made me think that Qt Creator changes few flags regarding build edition (but not all). “发布”这个词让我觉得 Qt Creator 改变了关于构建版本的几个标志(但不是全部)。 So I switched build edition to release (sets all flags to release), rebuild and back to debug edition (sets all flags to debug again) - it makes everything work fine.所以我将构建版本切换到发布(将所有标志设置为发布),重建并返回到调试版本(将所有标志设置为再次调试) - 这使一切正常。 It's always repeatable by me.我总是可以重复的。 Of course switching just to release mode also makes the problem go away as obviously it sets all build edition flags to sensible values.当然,仅切换到发布模式也会使问题消失,因为显然它将所有构建版本标志设置为合理的值。

Is it possible that the executable path in the run configuration of your project is incorrectly set?有没有可能是你项目运行配置中的可执行路径设置不正确?

I had this problem once.我曾经遇到过这个问题。 The default executable path was incorrect for some reason (QtCreator weirdness).由于某种原因,默认的可执行路径不正确(QtCreator 怪异)。 After adding a manual executable path with the proper content the problem was fixed.添加具有正确内容的手动可执行路径后,问题得到解决。

I'm using Qt Creator 3.3.2 and Qt 5.4.我正在使用 Qt Creator 3.3.2 和 Qt 5.4。 I encountered this problem after adding a new class.添加新类后我遇到了这个问题。 The solution was simple:解决方法很简单:

  1. Clean All清洁所有
  2. Manually delete make files手动删除make文件
  3. Restart Qt Creator重启 Qt Creator
  4. Run qmake运行 qmake
  5. Build all构建所有

Although I didn't test it, it's possible that simply restarting Qt Creator is sufficient.虽然我没有测试它,但可能只需重新启动 Qt Creator 就足够了。

I had same problem on iPad mini 2. I created new project from Xode (blank project from template) and deployed it to iPad.我在 iPad mini 2 上遇到了同样的问题。我从 Xode 创建了新项目(模板中的空白项目)并将其部署到 iPad。 After that Run and Debug buttons in Qt creator was enabled and I am able to deploy to iPad from Qt creator.在启用 Qt creator 中的 Run 和 Debug 按钮之后,我可以从 Qt creator 部署到 iPad。

I have also had this on Windows due to the limit on the number of characters in a path.由于路径中字符数的限制,我在 Windows 上也有这个。 The shadow build by default is quite verbose, and can easily max out the path limit.默认情况下的阴影构建非常冗长,并且可以轻松地最大化路径限制。

Changing the shadow build to eg build or build_ resolved this for me.将影子构建更改为例如 build 或 build_ 为我解决了这个问题。

Try to change or add the startup configuration, it will help to update the paths and settings.尝试更改或添加启动配置,这将有助于更新路径和设置。 You now:你现在:

Run configuration: untitled-2

It is most probably due to lack of Run Setting/Run Configuration.这很可能是由于缺少运行设置/运行配置。 I have it set and the problem is solved.我设置好了,问题解决了。

See the link at: https://doc.qt.io/qtcreator/creator-run-settings.html , check the section Specifying Run Settings for Qt Quick UI Projects for an example.请参阅以下链接: https : //doc.qt.io/qtcreator/creator-run-settings.html ,查看为 Qt Quick UI 项目指定运行设置部分的示例。

1 - Close Qt Creator 1 - 关闭 Qt Creator
2 - Delete project.pro.user file (not project.pro) 2 - 删除 project.pro.user 文件(不是 project.pro)
Note: if you have user setting then backup them because user settings will be lost注意:如果您有用户设置,请备份它们,因为用户设置将丢失
3- Re-open Project from project.pro 3- 从 project.pro 重新打开项目
4- Re-setup your project 4-重新设置您的项目
5- Enable Run and Debug Button. 5- 启用运行和调试按钮。

I just encountered a similar issue with the AUR package of the Qt Creator on arch linux.我刚刚在 arch linux 上的 Qt Creator 的 AUR package 遇到了类似的问题。

The solution was to download the original installer from the qt website and execute the.run file (After you made it executable):解决方案是从 qt 网站下载原始安装程序并执行 .run 文件(在您使其可执行之后):

https://www.qt.io/download https://www.qt.io/下载

You are welcome:)不客气:)

My anti-virus was responsible for disabling the run button.我的防病毒软件负责禁用运行按钮。 I disabled my anti-virus and restarted Qt.我禁用了我的防病毒软件并重新启动了 Qt。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM