1

我试图关注这篇文章:

http://www.ics.com/blog/combining-qt-widgets-and-qml-qwidgetcreatewindowcontainer#.UlVUExCXcnI

如果我尝试重做此操作,则会收到此错误:

15:13:36:项目 Test_QMLWidgets01 的运行步骤... 15:13:36:配置未更改,跳过 qmake 步骤。15:13:36:开始:“C:\Qt\Qt5\Tools\QtCreator\bin\jom.exe” C:\Qt\Qt5\Tools\QtCreator\bin\jom.exe -f Makefile.Debug cl -c -nologo -Zm200 -Zc:wchar_t -Zi -MDd -GR -W3 -w34100 -w34189 -EHsc -DUNICODE -DWIN32 -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -I"C:\Qt\Qt5\ 5.1.0\msvc2010\include" -I"C:\Qt\Qt5\5.1.0\msvc2010\include\QtWidgets" -I"C:\Qt\Qt5\5.1.0\msvc2010\include\QtGui" -I “C:\Qt\Qt5\5.1.0\msvc2010\include\QtANGLE”-I“C:\Qt\Qt5\5.1.0\msvc2010\include\QtCore”-I“调试”-I“。” -我”。” -I"C:\Qt\Qt5\5.1.0\msvc2010\mkspecs\win32-msvc2010"

所以我将 #include 更改为 #include 但随后出现链接错误:

15:16:27:项目 Test_QMLWidgets01 的运行步骤... 15:16:27:配置未更改,跳过 qmake 步骤。15:16:27:开始:“C:\Qt\Qt5\Tools\QtCreator\bin\jom.exe”C:\Qt\Qt5\Tools\QtCreator\bin\jom.exe -f Makefile.Debug cl -c -nologo -Zm200 -Zc:wchar_t -Zi -MDd -GR -W3 -w34100 -w34189 -EHsc -DUNICODE -DWIN32 -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -I"C:\Qt\Qt5\ 5.1.0\msvc2010\include" -I"C:\Qt\Qt5\5.1.0\msvc2010\include\QtWidgets" -I"C:\Qt\Qt5\5.1.0\msvc2010\include\QtGui" -I “C:\Qt\Qt5\5.1.0\msvc2010\include\QtANGLE”-I“C:\Qt\Qt5\5.1.0\msvc2010\include\QtCore”-I“调试”-I“。” -我”。” -I"C:\Qt\Qt5\5.1.0\msvc2010\mkspecs\win32-msvc2010"/ 24 / RT_MANIFEST */ "debug\Test_QMLWidgets01.exe.embed.manifest">debug\Test_QMLWidgets01.exe_manifest.rc 如果不存在 debug\Test_QMLWidgets01.exe 如果存在 debug\Test_QMLWidgets01.exe.embed.manifest del debug\Test_QMLWidgets01.exe .embed.manifest 如果存在 debug\Test_QMLWidgets01.exe.embed.manifest 复制 /Y debug\Test_QMLWidgets01.exe.embed.manifest debug\Test_QMLWidgets01.exe_manifest.bak 链接 /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY :type='win32' name='Microsoft.Windows.Common-Controls' 版本='6.0.0.0' publicKeyToken='6595b64144ccf1df' 语言=' 'processorArchitecture=''" /MANIFEST /MANIFESTFILE:debug\Test_QMLWidgets01.exe.embed.manifest /OUT:debug\Test_QMLWidgets01.exe @C:\Users\VANBEB~1\AppData\Local\Temp\Test_QMLWidgets01.exe.4220.2886.jom mainwindow.obj :错误 LNK2019:未解析的外部符号“__declspec(dllimport) public: void _ thiscall QQuickView::setSource(class QUrl const &)”( _imp_?setSource@QQuickView@@QAEXABVQUrl@@@Z) 在函数“public: __thiscall MainWindow”中引用::MainWindow(class QWidget *)" (??0MainWindow@@QAE@PAVQWidget@@@Z) mainwindow.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QQuickView::QQuickView(class QWindow *) " (_小鬼??0QQuickView@@QAE@PAVQWindow@@@Z) 在函数 "public: __thiscall MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QAE@PAVQWidget@@@Z) mainwindow.obj 中引用:错误 LNK2001 : 未解析的外部符号“public: virtual struct QMetaObject const * __thiscall QQuickView::metaObject(void)const” (?metaObject@QQuickView@@UBEPBUQMetaObject@@XZ) mainwindow.obj : 错误 LNK2001: 未解析的外部符号“public: virtual void * __thiscall QQuickView::qt_metacast(char const *)" (?qt_metacast@QQuickView@@UAEPAXPBD@Z) mainwindow.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall QQuickView::qt_metacall(enum QMetaObject::Call,int ,void * *)" (?qt_metacall@QQuickView@@UAEHW4Call@QMetaObject@@HPAPAX@Z) mainwindow.obj : error LNK2001: unresolved external symbol "protected: virtual bool __thiscall QQuickWindow::event(class QEvent *)" (?event@QQuickWindow@@MAE_NPAVQEvent@@@Z) mainwindow.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QQuickView::timerEvent(class QTimerEvent *)" (?timerEvent@QQuickView@@MAEXPAVQTimerEvent@@@Z) mainwindow.obj : 错误 LNK2001: 无法解析的外部符号 "public: virtual class QAccessibleInterface * __thiscall QQuickWindow::accessibleRoot(void)const " (?accessibleRoot@QQuickWindow@ @UBEPAVQAccessibleInterface@@XZ) mainwindow.obj:错误 LNK2001:未解析的外部符号“公共:虚拟类 QObject * __thiscall QQuickWindow::focusObject(void)const”(?focusObject@QQuickWindow@@UBEPAVQObject@@XZ) mainwindow.obj:错误LNK2001:未解析的外部符号“受保护:virtual void __thiscall QQuickWindow::exposeEvent(class QExposeEvent *)" (?exposeEvent@QQuickWindow@@MAEXPAVQExposeEvent@@@Z) mainwindow.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QQuickView::resizeEvent(class QResizeEvent * )" (?resizeEvent@QQuickView@@MAEXPAVQResizeEvent@@@Z) mainwindow.obj:错误 LNK2001:未解析的外部符号“受保护:虚拟 void __thiscall QQuickWindow::focusInEvent(class QFocusEvent *)”(?focusInEvent@QQuickWindow@@MAEXPAVQFocusEvent@ @@Z) mainwindow.obj : 错误 LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QQuickWindow::focusOutEvent(class QFocusEvent *)" (?focusOutEvent@QQuickWindow@@MAEXPAVQFocusEvent@@@Z) mainwindow.obj : 错误 LNK2001:未解析的外部符号“受保护:virtual void __thiscall QQuickWindow::showEvent(class QShowEvent *)" (?showEvent@QQuickWindow@@MAEXPAVQShowEvent@@@Z) mainwindow.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QQuickWindow::hideEvent(class QHideEvent * )" (?hideEvent@QQuickWindow@@MAEXPAVQHideEvent@@@Z) mainwindow.obj:错误 LNK2001:未解析的外部符号“受保护:虚拟 void __thiscall QQuickView::keyPressEvent(class QKeyEvent *)”(?keyPressEvent@QQuickView@@MAEXPAVQKeyEvent@ @@Z) mainwindow.obj : 错误 LNK2001: 无法解析的外部符号 "protected: virtual void __thiscall QQuickView::keyReleaseEvent(class QKeyEvent *)" (?keyReleaseEvent@QQuickView@@MAEXPAVQKeyEvent@@@Z) mainwindow.obj : 错误 LNK2001:未解析的外部符号“受保护:virtual void __thiscall QQuickView::mousePressEvent(class QMouseEvent *)" (?mousePressEvent@QQuickView@@MAEXPAVQMouseEvent@@@Z) mainwindow.obj : 错误 LNK2001: 未解析的外部符号 "protected: virtual void __thiscall QQuickView::mouseReleaseEvent(class QMouseEvent *)" (?mouseReleaseEvent@ QQuickView@@MAEXPAVQMouseEvent@@@Z) mainwindow.obj:错误 LNK2001:无法解析的外部符号“受保护:虚拟 void __thiscall QQuickWindow::mouseDoubleClickEvent(类 QMouseEvent *)”(?mouseDoubleClickEvent@QQuickWindow@@MAEXPAVQMouseEvent@@@Z) 主窗口。 obj:错误 LNK2001:未解析的外部符号“受保护:虚拟 void __thiscall QQuickView::mouseMoveEvent(类 QMouseEvent *)”(?mouseMoveEvent@QQuickView@@MAEXPAVQMouseEvent@@@Z)mainwindow.obj:错误 LNK2001:未解析的外部符号“受保护:virtual void __thiscall QQuickWindow::wheelEvent(class QWheelEvent *)" (?wheelEvent@QQuickWindow@@MAEXPAVQWheelEvent@@@Z) mainwindow.obj : 错误 LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: virtual _thiscall QQuickView::~QQuickView(void)" ( _imp_??1QQuickView@@UAE@XZ) 在函数 "public: virtual void * _ thiscall QQuickView:: scalar deleting destructor'(unsigned int)" (??_GQQuickView@@UAEPAXI@Z) mainwindow.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QQmlDebuggingEnabler::QQmlDebuggingEnabler(bool)" (__imp_??0QQmlDebuggingEnabler@@QAE@_N@Z) referenced in function "void __cdecl'qmlEnableDebuggingHelper''(void)" (??_EqmlEnableDebuggingHelper@@YAXXZ) debug\Test_QMLWidgets01.exe:致命错误 LNK1120:24 个未解决的外部 jom:E:\QtProjects\build-Test_QMLWidgets01-Desktop_Qt_5_1_0_MSVC2010_32bit-Debug\Makefile.Debug [debug\Test_QMLWidgets01.exe] 错误 1120:\mjo QtProjects\build-Test_QMLWidgets01-Desktop_Qt_5_1_0_MSVC2010_32bit-Debug\Makefile [debug] Error 2 15:16:30: The process "C:\Qt\Qt5\Tools\QtCreator\bin\jom.exe" exited with code 2. 构建时出错/deploying project Test_QMLWidgets01(套件:Desktop Qt 5.1.0 MSVC2010 32bit)执行步骤“Make”时 15:16:30:经过时间:00:04。

我究竟做错了什么?

4

1 回答 1

6

我认为您需要添加到您的.pro文件中: QT += core gui widgets quick

于 2013-10-09T14:33:54.077 回答