尝试在Qt中获取自定义窗口框架时LNK2019问题
LNK2019 problems when trying to get custom window frame in Qt
我想要一个自定义窗口框架,用于我在Qt 5.4中使用QML制作的应用程序。在我的主项目上实现它之前,我在默认应用程序上尝试了以下内容:
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
//QQmlApplicationEngine engine;
//engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
QDeclarativeView view;
viewsetWindowFlags(Qt::FramelessWindowHint
| Qt::WindowSystemMenuHint
| Qt::WindowMinimizeButtonHint
| Qt::Window);
view.setAttribute(Qt::WA_TranslucentBackground);
view.setMaximumHeight(640);
view.setMaximumWidth(350);
view.viewport()->setAutoFillBackground(false);
view.show();
return app.exec();
}
这是.pro
文件:
TEMPLATE = app
QT += qml quick widgets
QT += core gui widgets quick
QT += network
SOURCES += main.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Default rules for deployment.
include(deployment.pri)
错误:
main.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QDeclarativeDebuggingEnabler::QDeclarativeDebuggingEnabler(void)" (__imp_??0QDeclarativeDebuggingEnabler@@QEAA@XZ) referenced in function "void __cdecl `dynamic initializer for 'qmlEnableDebuggingHelper''(void)" (??__EqmlEnableDebuggingHelper@@YAXXZ)
main.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QDeclarativeView::QDeclarativeView(class QWidget *)" (__imp_??0QDeclarativeView@@QEAA@PEAVQWidget@@@Z) referenced in function main
main.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl QDeclarativeView::~QDeclarativeView(void)" (__imp_??1QDeclarativeView@@UEAA@XZ) referenced in function main
我知道这与我的 .pro 文件有关,但在理解 LNk 错误方面不太好,到目前为止,我已经尝试了不同的事情但没有进展。如何解决这个问题?
添加到 pro 文件:
QT += declarative
从文档中:
为了移植较旧的应用程序,Qt声明式 模块在Qt 5中仍然可用,但已重命名为Qt Quick 1。 需要Qt Quick 1特定API的应用程序(例如 QDeclarativeView 或 QDeclarativeItem 和图形视图 集成)可以使用此模块。请注意,新应用程序应 改用新的Qt QML和Qt Quick模块。
要使用Qt Quick 1模块,请将"声明式"添加到qmake .pro 文件:
可以包含所需的头文件,如下所示:
#include <QtDeclarative/QDeclarativeView>
#include <QtDeclarative/QDeclarativeItem>
也:
以前在 Qt声明式模块中的所有类都是 移到Qt QML和Qt Quick模块中,它们的类名有 已更改以反映其新模块位置。类名 更改如下:
。QDeclarativeView -> QQuickView
但:
(QtDeclarative模块仍可作为Qt提供给开发人员 快速 1 模块,如下所述。但是,它不应用于 新应用程序。
相关文章:
- 如何在Qt窗口小部件中使用QStringView(或QStringRef)
- 问:如何使用C++中的按钮从窗口打开窗口
- SDL 窗口不会弹出
- 如何将不同的可执行文件合并到一个窗口框架中进行编码?像浏览器一样
- 延迟函数使打开的框架窗口冻结,直到指定的时间过去
- 有没有办法知道父窗口的类型(基于框架或对话框)?
- EVR在播放前固定后在窗口上显示几个黑色框架
- 获取主框架窗口
- 我自己的C++框架(类似MFC),我可以创建子窗口,但不能在WM_create时创建编辑框
- 尝试在Qt中获取自定义窗口框架时LNK2019问题
- 使用谷歌测试框架(不是窗口)检测内存泄漏的标准做法是什么?
- 用于windows上的窗口系统的win32框架的替代方案
- 如何创建一个没有窗口框架的应用程序
- 在创建任何窗口之前,如何获取窗口框架的宽度
- 如何在Qt无框架窗口中实现QSizeGrip
- 如何在Qt应用程序中编辑默认的窗口标题和框架?
- Qt Ui设计器-创建窗口默认框架和默认按钮
- Gtkmm 3.0如何在框架或窗口之间切换
- 用户界面 - 测试C++ GUI 桌面窗口应用的自动化工具/库/框架
- 删除 Win32 C++中的标准窗口框架