安装 Qt Quick Components for Desktop 以与 Qt Creator 一起使用

发布于 2024-11-14 15:11:23 字数 385 浏览 0 评论 0原文

我正在尝试使用 中的 Qt Quick Components for Desktop http://labs.qt.nokia.com/2011/03/10/qml-components-for-desktop/

我可以将它构建并安装到它自己的文件夹中,并且使用 qmlviewer 查看 qml,但如何在 Qt Creator 中使用其他项目中的这些 qml 组件?

例如,我希望能够使用 Qt Quick Components for Desktop 中的 Dial.qml 在我的项目中的 qml 文件中创建 Dial 元素。

I'm trying to use Qt Quick Components for Desktop from http://labs.qt.nokia.com/2011/03/10/qml-components-for-desktop/

I can build and install it just fine into it's own folder, and view the qmls with qmlviewer, but how do I use these qml components from my other projects in Qt Creator?

For example, I'd like to be able to use Dial.qml from the Qt Quick Components for Desktop to make a Dial element in a qml file in my project.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

对你的占有欲 2024-11-21 15:11:23

我使用了这个问题的答案中的说明: Qt 如何制作和安装插件? 并能够在 qt 创建者 qml 文件中成功使用 qt 快速桌面组件。以下是我所做的更详细说明:

  1. http://下载 tar.gz /qt.gitorious.org/qt-components/desktop/trees/master
  2. 将组件提取到任意位置(例如 C:\qt-components-desktop)。
  3. 打开命令提示符。
  4. 在命令提示符下从“您的 Visual Studio”\VC\bin\ 目录...(通常为 C:\Program Files\Microsoft Visual Studio 9.0\VC\bin)运行 vcvars32.bat。
    例如“C:\ Program Files \ Microsoft Visual Studio 9.0 \ VC \ bin \ vcvars32.bat”
    您应该收到类似以下内容的消息:“正在设置使用 Microsoft Visual Studio 2008 x86 工具的环境”
  5. 设置命令提示符以使用 Qt Creator 的 bin 路径...(通常为 C:\Qt\qtcreator-2.1.0\bin)。
    例如 SET PATH=%PATH%;C:\Qt\qtcreator-2.1.0\bin
  6. 设置命令提示符以使用 Qt 的 bin 路径...(通常为 C:\Qt\4.7.2\bin)。
    例如 SET PATH=%PATH%;C:\Qt\4.7.2\bin
  7. 在命令提示符下导航到提取 qt 桌面组件的文件夹。
  8. 运行以下命令:
    qmake
    乔姆调试
    jom install
  9. 从提取 qt 桌面组件的位置复制“组件”文件夹。
  10. 将其放在“您的 Qt 目录”\imports\Qt\labs ...(通常为 C:\Qt\4.7.2\imports\Qt\labs)
  11. 中 在任何文本编辑器中打开 Components 文件夹内的 qmldir 文件并观察版本每行数字(例如 0.1)
  12. 将以下导入语句放入任何 qml 文件中以使用 Qt 桌面组件:
    导入 Qt.labs.components #.#
    其中 #.# 是您的版本号(例如 0.1)

I used the instructions from the answer for this question: Qt How to make and install plugins? and was able to successfully use the qt quick desktop components within qt creator qml files. Here are more detailed instructions that I made:

  1. Download the tar.gz from http://qt.gitorious.org/qt-components/desktop/trees/master
  2. Extract the components anywhere (e.g. C:\qt-components-desktop).
  3. Open command prompt.
  4. run vcvars32.bat from "your Visual Studio"\VC\bin\ directory ... (usually C:\Program Files\Microsoft Visual Studio 9.0\VC\bin) in command prompt.
    e.g. "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"
    You should receive a message similar to: "Setting environment for using Microsoft Visual Studio 2008 x86 tools"
  5. Set command prompt to use Qt Creator's bin path ... (usually C:\Qt\qtcreator-2.1.0\bin).
    e.g. SET PATH=%PATH%;C:\Qt\qtcreator-2.1.0\bin
  6. Set command prompt to use Qt's bin path ... (usually C:\Qt\4.7.2\bin).
    e.g. SET PATH=%PATH%;C:\Qt\4.7.2\bin
  7. Navigate in command prompt to the folder where you extracted the qt desktop components.
  8. Run the following commands:
    qmake
    jom debug
    jom install
  9. Copy the "components" folder from where you extracted the qt desktop components.
  10. Place it in "your Qt directory"\imports\Qt\labs ... (usually C:\Qt\4.7.2\imports\Qt\labs)
  11. Open the qmldir file inside the components folder in any text editor and observe the version number on each line (e.g. 0.1)
  12. Place the following import statement in any qml file to use Qt desktop components:
    import Qt.labs.components #.#
    where #.# is your version number (e.g. 0.1)
我的鱼塘能养鲲 2024-11-21 15:11:23
  1. http://qt.gitorious.org/qt-components 下载 tar.gz /desktop/trees/master
  2. 解压
  3. 启动 vcvars32.bat,然后转到 qt-components-desktop\ 文件夹
  4. 转到 qt-components-desktop\components\ 文件夹(cd elements),输入“qmake && nmake install”
  5. 转到 qt-components-desktop\src\ 文件夹,输入“qmake && nmake install”
  1. Download the tar.gz from http://qt.gitorious.org/qt-components/desktop/trees/master
  2. unpack
  3. launch vcvars32.bat, then go to qt-components-desktop\ folder
  4. go to qt-components-desktop\components\ folder (cd components), type "qmake && nmake install"
  5. go to qt-components-desktop\src\ folder, type "qmake && nmake install"
玩心态 2024-11-21 15:11:23

这些是使用 Windows 系统和 Qt 附带的 mingw 的替代步骤。对于本示例,我将 Qt SDK 安装到 C:\QtSDK。对于这些说明,我使用了 Qt 4.8.1。

  1. http://qt.gitorious.org/qt-components 下载 tar.gz /desktop/trees/master
  2. 解压组件
  3. 使用以下两个选项之一将 Qt 的桌面 mingw bin 路径和 Qt 的 mingw bin 路径添加到 PATH 系统变量:
    • 选项 1:(持续)使用控制面板。 (http ://www.computerhope.com/issues/ch000549.htm
      1. 导航至“控制面板”-> 「系统」-> “高级系统设置”
      2. 选择“高级”标签
      3. 按“环境变量...”按钮,该按钮位于第三个组合框下方、“确定/取消”按钮上方
      4. 在“系统变量”组框下,滚动列表并找到“路径”变量
      5. 双击或选择“Path”变量,然后按“编辑...”
      6. 通过在字段内单击并按键盘上的 END 或使用鼠标滚动至末尾,转到“变量值:”字段的最右端。
      7. 添加分号;,然后添加Qt的mingw bin目录的路径,本例中为C:\QtSDK\mingw\bin
      8. 在末尾添加另一个分号,然后在您使用的 Qt 版本中添加 Qt 的 Desktop mingw bin 目录,在本例中为 4.8.1: ;C:\QtSDK\Desktop\Qt\4.8。 1\mingw\bin
      9. 最后,路径变量的添加应如下所示:;C:\QtSDK\mingw\bin;C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin。请注意,这些路径也可以添加到路径变量中的任何位置,无论顺序如何。
      10. 按“确定”按钮关闭所有打开的窗口并保存您的更改。
    • 选项 2:(临时)使用 SET 命令。此方法仅在执行的命令提示符窗口内持续。如果命令提示符窗口关闭,则必须重新输入 SET 命令。
      1. 使用SET PATH=%PATH%;C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin添加Qt的桌面mingw bin目录
      2. 使用SET PATH=%PATH%;C:\QtSDK\mingw\bin添加Qt的mingw bin目录
      3. 使用同一命令提示符窗口继续执行以下步骤。 SET 命令仅针对您执行它们的特定命令提示符窗口进行设置。
  4. 如果使用选项 1,请打开新的命令提示符并导航到提取 qt 桌面组件的位置。如果使用选项 2,请使用相同的命令提示符导航到 qt 桌面组件文件夹
  5. 运行以下命令:qmake && mingw-make install
  6. 该命令会自动将编译好的组件文件复制到C:\QtSDK\Desktop\Qt\4.8.1\mingw\imports\QtDesktop所以不需要手动移动或创建任何文件夹。
  7. 新建一个Qt Desktop工程,选择与Qt版本匹配的mingw作为工具链。
  8. 尝试编译并运行以下代码:

    导入QtQuick 1.1
    导入QtDesktop 0.1
    
    长方形 {
        宽度:100
        高度:100
        按钮 {
            id: 按钮
            文字:“推我”
            onClicked: Button.text = "按下"
        }
    }
    
  9. 完成

在执行这些指令时,QtDesktop 组件的最新版本是 0.1。要检查您安装的版本,请导航至 C:\QtSDK\Desktop\Qt\4.8.1\mingw\imports\QtDesktop 并使用文本编辑器打开文件 qmldir并注意每行的版本号。

These are alternative steps using a windows system and mingw which comes with Qt. For this example, I installed the Qt SDK to C:\QtSDK. For these instructions, I used Qt 4.8.1.

  1. Download the tar.gz from http://qt.gitorious.org/qt-components/desktop/trees/master
  2. Unpack the components
  3. Add Qt's Desktop mingw bin path and Qt's mingw bin path to the PATH system variable with one of the two options:
    • Option 1: (persistent) Using the control panel. (http://www.computerhope.com/issues/ch000549.htm)
      1. Navigate to "Control Panel" -> "System" -> "Advanced system settings"
      2. Select the "Advanced" tab
      3. Press the "Environment Variables..." button, located below the third groupbox and above the OK/Cancel button
      4. Under the "System variables" groupbox, scroll through the list and find the "Path" variable
      5. Double click or select the "Path" variable and press "Edit..."
      6. Go to the right-most end of the "Variable value:" field by either clicking within the field and pressing END on your keyboard or scrolling to the end with your mouse.
      7. Add a semicolon ; then the path to Qt's mingw bin directory, in this case it is C:\QtSDK\mingw\bin
      8. Add another semicolon to the end and then Qt's Desktop mingw bin directory located in the version of Qt you are using, in this case it is 4.8.1: ;C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin
      9. In the end, the addition to the path variable should look like this: ;C:\QtSDK\mingw\bin;C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin. Note that these paths could also be added anywhere and whichever order within the path variable.
      10. Press "OK" to all opened windows to close and save your changes.
    • Option 2: (temporary) Using the SET command. This method only lasts within the command prompt window it was executed. If the command prompt window is closed, the SET commands must be re-entered.
      1. Add Qt's Desktop mingw bin directory with SET PATH=%PATH%;C:\QtSDK\Desktop\Qt\4.8.1\mingw\bin
      2. Add Qt's mingw bin directory with SET PATH=%PATH%;C:\QtSDK\mingw\bin
      3. Continue the steps below with this same command prompt window. The SET commands are only set for the specific command prompt window you executed them in.
  4. If option 1 was used, open a new command prompt and navigate to where the qt desktop components are extracted. If option 2 was used, use the same command prompt to navigate to the qt desktop components folder
  5. Run the following command: qmake && mingw-make install
  6. This command will automatically copy the compiled component files to C:\QtSDK\Desktop\Qt\4.8.1\mingw\imports\QtDesktop so there is no need to manually move or create any folders.
  7. Make a new Qt Desktop project, and select the mingw which matches the Qt version as the toolchain.
  8. Attempt to compile and run the following code:

    import QtQuick 1.1
    import QtDesktop 0.1
    
    Rectangle {
        width: 100
        height: 100
        Button {
            id: button
            text: "Push me"
            onClicked: button.text = "Pressed"
        }
    }
    
  9. Done

At the time of these instructions, the latest version of the QtDesktop components is 0.1. To check the version you installed, navigate to C:\QtSDK\Desktop\Qt\4.8.1\mingw\imports\QtDesktop and open the file qmldir with a text editor and notice the version number on each line.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文