“设计”按钮在 QML 项目的 Qt Creator 中呈灰色
我在 Kubuntu 11 系统上尝试我的第一个 Qt Quick 项目。由于这是 Kubuntu,我只是使用它附带的 Qt 运行,到目前为止它运行良好。
我要求 Qt Creator 从 Qt Quick 创建示例“Hello World”项目。但设计按钮和运行按钮都是灰色的。
起初,当我进入“运行设置”下的“项目”菜单时,它显示Qt版本:[无效的Qt版本]。按“管理 Qt 版本”按钮会弹出一个树形控件,如下所示:
v -- Auto-detected
| |
| +---Qt in PATH /usr/bin/qmake-qt4
|
+--- Manual
在对话框底部显示“Found Qt version 4.7.2, using mkspec linux-g++ (Desktop)”
我发现我可以通过手动选择 从应用程序存储库安装 QmlViewer。您可能认为它会说更像“未找到 Qml Viewer,请安装它”之类的内容,但是......哦,好吧。现在它显示Qt Version: [Qt in PATH]。
这样问题就解决了,Qml 应用程序就可以运行了。但“设计”按钮仍然是灰色的。 Qt Designer 作为应用程序安装,其插件显示在“关于插件...”列表中。当我单击表单文件时,设计按钮在普通(非 Qt-Quick)项目中启用,但不适用于 .qml 文件。
I'm on a Kubuntu 11 system and trying out my first Qt Quick project. As this is Kubuntu I'm just running with the Qt that came with it, which has worked fine so far.
I asked Qt Creator to create the sample "Hello World" project from Qt Quick. But the design button was grayed out, as were the run buttons.
At first when I went into the Projects menu under "Run Settings" it said Qt version: [Invalid Qt Version]. Pushing the "Manage Qt versions" button brings up a tree control that looks like this:
v -- Auto-detected
| |
| +---Qt in PATH /usr/bin/qmake-qt4
|
+--- Manual
At the bottom of the dialog it says "Found Qt version 4.7.2, using mkspec linux-g++ (Desktop)"
I found out that I could get the "Invalid Qt version" message to go away by manually choosing to install QmlViewer from the app repositories. You'd think it would say something more like "Qml Viewer not found, please install it" but...oh well. Now it says Qt Version: [Qt in PATH].
So that's fixed, and the Qml app runs. But the "Design" button is still grayed out. Qt Designer is installed as an application, and its plugin shows in the "About Plugins..." list. The design button is enabled in ordinary (non-Qt-Quick) projects when I click on a form file, just not for .qml files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 QtCreator 中,转到帮助 ->关于插件->选择“QT 快速”。
重新启动 QtCreator,然后选择 ui.qml 文件。现在应该可以了
in the QtCreator, go to Help -> About plugins -> Select "QT Quick".
Restart QtCreator and then select the ui.qml files. It should work now
就我而言,它没有显示,因为我打开了 cpp 文件。当我双击
.ui
文件时,设计按钮变为活动状态。In my case it wasn't showing up because I had my cpp file open. When I double clicked on the
.ui
file, the design button became active.写问题的时候就解决了。
长话短说:这似乎是通过 ubuntu 存储库安装 Qt Creator 的一个已知问题,而不是使用诺基亚的 Qt SDK 安装程序:
http://qt.nokia.com/downloads
(该安装程序似乎负责确保安装正确的 SDK 元素,而 Linux 软件包存储库滞后)
另一种选择似乎是从源代码构建 Qt。但是卸载我通过 KPackageKit 获得的 Qt Creator 并使用诺基亚的安装程序则涉及较少,并且在这种情况下对我有用。
Solved it while writing the question.
To make a long story short: this appears to be a known issue in general with installing Qt Creator through the ubuntu repositories as opposed to using the Qt SDK Installer from Nokia:
http://qt.nokia.com/downloads
(That installer seems to do the work of making sure the proper SDK elements are installed, while the linux package repositories lag in getting things right.)
Another option seems to be building Qt from sources. But uninstalling the Qt Creator I got through KPackageKit and instead using the installer from Nokia was less involved, and worked for me in this case.