繁体   English   中英

Qt for Visual Studio 2017 的 C++ 编译问题

[英]C++ compile problems with Qt for Visual Studio 2017

我已经使用msvc2017_64二进制文件安装了 Qt Creator。 我还为 VS2017 安装了 Qt 插件。 我可以毫无问题地创建 QtGuiApplication,但是当我尝试编译它时,会出现许多错误。 在此处在 pastebin 上列出了它们,因为我无法将这么多字符添加到 Stackoverflow。 我很抱歉。

我需要任何必要的包吗? 我为 VS2017 ofc 安装了 C++。 我还在 Qt VS 工具菜单中包含了 QtPath。

我没有编辑文件,因为项目创建和编译由于错误而失败。


编辑:这个问题在这里解决 但不仅存在错误表单 Pastebin,还有QtGuiApplication.h中的错误


QtGuiApplication.h:(错误标记为注释)

#pragma once

#include <QtWidgets/QMainWindow>
#include "ui_QtGuiApplication1.h" //This could not be found

class QtGuiApplication1 : public QMainWindow
{
    Q_OBJECT

public:
    QtGuiApplication1(QWidget *parent = Q_NULLPTR);

private:
    Ui::QtGuiApplication1Class ui; //Ui namespace does not exist
};

QtApplication.cpp:

#include "stdafx.h"
#include "QtGuiApplication1.h"

QtGuiApplication1::QtGuiApplication1(QWidget *parent)
    : QMainWindow(parent)
{
    ui.setupUi(this);
}

主.cpp:

#include "stdafx.h"
#include "QtGuiApplication1.h"
#include <QtWidgets/QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QtGuiApplication1 w;
    w.show();
    return a.exec();
}

我自己解决了这个问题!

Qt 插件使用 Windowns 8.1 SDK 创建项目,您需要将其重新定位到 Win 10 SDK 以从 QtGuiApplication.h 中获取编译错误。 即使安装了 8.1 SDK。 好像是个bug。

解决方案对我来说非常简单,只需从解决方案资源管理器卸载然后重新加载解决方案! 这将清除所有 C++ 编译器错误! 不知道为什么...

暂无
暂无

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

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