简体   繁体   English

如何在 Visual Studio 中制作 Qt Quick 应用程序?

[英]How do you make Qt Quick applications in Visual Studio?

I'm trying to learn Qt and I'm still somewhat new to programming in general, and I prefer to do my coding in VS (2015), since that's what I know, but I can't figure out how to make Qt Quick applications.我正在尝试学习 Qt,但总的来说,我对编程还是有些陌生,我更喜欢在 VS(2015)中进行编码,因为这是我所知道的,但我不知道如何使 Qt Quick应用程序。 I've installed the VS Tools plugin for Qt, but it doesn't have an option in the setup wizard for a QML project, only a widgets project, and that's about the extent of my knowledge of how to set something like that up.我已经为 Qt 安装了 VS Tools 插件,但它在 QML 项目的设置向导中没有一个选项,只有一个小部件项目,这就是我对如何设置类似内容的了解程度。 I've been googling for most of the day to try to figure out how to do it, and I've found plenty of examples of people using Quick projects in VS without problem, but no examples of how to actually set it up to begin with.我一天中的大部分时间都在用谷歌搜索,试图弄清楚如何去做,我发现了很多人在 VS 中使用 Quick 项目没有问题的例子,但没有关于如何实际设置它的例子开始和。 What do I need to do?我需要做什么?

The following answer is intended for VS 2019 with Qt 5.13.1 and Qt Creator 4.10.以下答案适用于带有 Qt 5.13.1 和 Qt Creator 4.10 的 VS 2019。 If that differs from what you are working with, I hope the instructions are similar enough.如果这与您正在使用的不同,我希望这些说明足够相似。

  1. Open up QT Creator, select "File" > "New File or Project", then choose any of the templates with "Qt Quick Application" in their title.打开 QT Creator,选择“文件”>“新建文件或项目”,然后选择标题中带有“Qt Quick Application”的任何模板。
  2. Go through the rest of the setup dialog.完成设置对话框的其余部分。 The default options for rest of the steps should work fine.其余步骤的默认选项应该可以正常工作。 Create your project.创建您的项目。
  3. In Qt Creator, in the lower left corner, click the button that says "Unconfigured", then click the text that allows you to configure it in projects mode.在 Qt Creator 的左下角,单击“未配置”按钮,然后单击允许您在项目模式下对其进行配置的文本。 This will bring up a dialog.这将打开一个对话框。 Click "Configure Project".单击“配置项目”。 Wait for your project to generate.等待您的项目生成。 This will "fill out" your project, and give you the basic files for your template.这将“填写”您的项目,并为您提供模板的基本文件。
  4. Open up Visual Studio.打开 Visual Studio。 Go to the editor without selecting a project or folder.转到编辑器而不选择项目或文件夹。 For VS 2019, there is a small link on the bottom right side of the screen that says "Continue without code" that allows you to do this.对于 VS 2019,屏幕右下方有一个小链接,上面写着“Continue without code”,允许您执行此操作。
  5. Find the menu for your Qt VS Tools extension.找到 Qt VS Tools 扩展的菜单。 For VS 2019, you will simply click "Extensions" > "Qt VS Tools".对于 VS 2019,您只需单击“扩展”>“Qt VS 工具”。 For VS 2015 and 2017, I'm not sure where it is, but it's probably in "Tools" somewhere.对于 VS 2015 和 2017,我不确定它在哪里,但它可能在某个地方的“工具”中。
  6. Click "Open Qt Project File" or similar.单击“打开 Qt 项目文件”或类似的。 Find the .pro file generated by Qt Creator and open it.找到Qt Creator生成的.pro文件,打开。
  7. Visual studio will now generate your new solution and project. Visual Studio 现在将生成您的新解决方案和项目。 It should build and run out of the box, and you shouldn't have to mess with your .vcxproj or .pro files.它应该是开箱即用的,您不必弄乱您的 .vcxproj 或 .pro 文件。

Source: How to convert QtCreator project to Visual Studio project来源: 如何将 QtCreator 项目转换为 Visual Studio 项目

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

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