c++ - VS2019 无法正确导入 Qt Designer 项目
问题描述
我到处寻找解决方案,但我找不到。在 VS2019 中,我安装了 Qt 工具扩展,并从 Qt Designer 中导出了 C++ 头文件,包括我的项目。然后我创建了一个 .pro 文件,包括:
QT += widgets
QT += uitools
HEADERS += ui_xinterface.h
FORMS += xinterface.ui
SOURCES += main.cpp
然后我将它导入到 VS2019 中,它会自动创建一个项目。然后我将此函数添加到 main.cpp,按照此示例(注意:main.cpp 最初是一个空文件):
#include <QtUiTools>
#include "ui_xinterface.h"
static QWidget* loadUiFile(QWidget* parent)
{
QFile file(":/forms/xinterface.ui");
file.open(QIODevice::ReadOnly);
QUiLoader loader;
return loader.load(&file, parent);
}
这没有建立:
Build started...
1>------ Build started: Project: ui_interface, Configuration: Debug x64 ------
1>main.cpp
1>Qt6EntryPointd.lib(qtentrypoint_win.cpp.obj) : error LNK2019: unresolved external symbol main referenced in function WinMain
1>debug\\ui_interface.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "ui_interface.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
并给出了 9 个错误:
Severity Code Description Project File Line Suppression State
Error LNK1120 1 unresolved externals ui_interface C:\Users\User\Documents\EE\basic-app\debug\ui_interface.exe 1
Error LNK2019 unresolved external symbol main referenced in function WinMain ui_interface C:\Users\User\Documents\EE\basic-app\Qt6EntryPointd.lib(qtentrypoint_win.cpp.obj) 1
Error (active) E2422 defaulted default constructor cannot be constexpr because the corresponding implicitly declared default constructor would not be constexpr ui_interface C:\Qt\6.2.0\msvc2019_64\include\QtCore\qmetatype.h 444
Error (active) E0028 expression must have a constant value ui_interface C:\Qt\6.2.0\msvc2019_64\include\QtCore\qmetatype.h 2181
Error (active) E0028 expression must have a constant value ui_interface C:\Qt\6.2.0\msvc2019_64\include\QtCore\qmetatype.h 2261
Error (active) E2422 defaulted default constructor cannot be constexpr because the corresponding implicitly declared default constructor would not be constexpr ui_interface C:\Qt\6.2.0\msvc2019_64\include\QtCore\qmutex.h 150
Error (active) E2422 defaulted default constructor cannot be constexpr because the corresponding implicitly declared default constructor would not be constexpr ui_interface C:\Qt\6.2.0\msvc2019_64\include\QtCore\qmutex.h 205
Error (active) E2422 defaulted default constructor cannot be constexpr because the corresponding implicitly declared default constructor would not be constexpr ui_interface C:\Qt\6.2.0\msvc2019_64\include\QtCore\qproperty.h 255
Error (active) E2422 defaulted default constructor cannot be constexpr because the corresponding implicitly declared default constructor would not be constexpr ui_interface C:\Qt\6.2.0\msvc2019_64\include\QtCore\qrunnable.h 56*
这些看起来像是链接器错误,但我不知道如何修复它们。附加库 [$(Qt_INCLUDEPATH_)] 和目录 [$(Qt_LIBPATH_)] 似乎在项目属性中自动链接。我对此很陌生,我错过了什么?
解决方案
推荐阅读
- sql - 带有开始和停止的子句分区
- javascript - Vue.js 从外部 js 文件调用异步函数
- javascript - 是这个 w3schools javascript 示例的错误,还是我的错误?
- php - 从子关系 OOP Laravel 中获取父模型
- reactjs - 如何在反应中将单个字母与 onChange 事件分开?
- python - 无法使用 pythons SPARQLWrapper 从 GraphDB 中删除任何三元组
- javascript - 如何根据我的代码和 JSON 响应对象显示下拉菜单列表?
- python - 通过从列表中获取值,根据列值动态删除 Pandas 中的 DataFrame 行
- mysql - 如何使此选择查找另一个表并找到第一个匹配项?
- bash - uniq -c 用于计算文件中的重复行不起作用