首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >QT5 QWebView链接器错误

QT5 QWebView链接器错误
EN

Stack Overflow用户
提问于 2013-01-28 07:23:58
回答 2查看 13.7K关注 0票数 18

现在我只是想让“www.google.com”在一个按钮被按下的时候加载到网页视图中。在我将webview添加到设计器中之后,链接器开始疯狂。我在Windows7上使用QT Creater 2.6.1和QT5。我在.pro文件中添加了QT += 'webkit内容‘。我已经尝试过清理和重建,仍然收到链接器错误。

由于某种奇怪的原因,在任何文件中添加"#include <QWebView>“都会产生文件未找到错误:"C:\Users\Scott\Desktop\eCookBook\eCookBook2\cookbook.cpp:3:错误: C1083:无法打开包含文件:'QWebView':没有这样的文件或目录”

cookbook.h:

#ifndef COOKBOOK_H
#define COOKBOOK_H

#include <QMainWindow>
#include <QtWebKit/QWebElement>
#include <QtWebKit/QtWebKit>
#include <QtWebKitWidgets/QWebPage>

namespace Ui {
class cookBook;
}

class cookBook : public QMainWindow
{
    Q_OBJECT

public:
    explicit cookBook(QWidget *parent = 0);
    ~cookBook();

private slots:
    void on_pushButton_clicked();

    void on_textBrowser_anchorClicked(const QUrl &arg1);


private:
    Ui::cookBook *ui;
    //QWebPage page;
};

#endif // COOKBOOK_H

cookbook.cpp

#include "cookbook.h"
#include "ui_cookbook.h"
//#include <QWebView>
//#include <QtWebKit/QtWebKit>

cookBook::cookBook(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::cookBook)
{
    ui->setupUi(this);
}

cookBook::~cookBook()
{
    delete ui;
}


void cookBook::on_pushButton_clicked()
{
    ui->listWidgetTest->insertItem(ui->listWidgetTest->count(), "TEST");

    const QUrl testsite = "www.google.com";
    ui->widget->load(testsite);
    ui->widget->show();

}

.pro文件

#-------------------------------------------------
#
# Project created by QtCreator 2013-01-23T14:46:45
#
#-------------------------------------------------

QT       += core gui
QT += webkit
QT += webkit webkitwidgets


greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = eCookBook2
TEMPLATE = app


SOURCES += main.cpp\
        cookbook.cpp

HEADERS  += cookbook.h

FORMS    += cookbook.ui

编译器输出:

15:04:58: Running steps for project eCookBook2...
15:04:58: Configuration unchanged, skipping qmake step.
15:04:58: Starting: "C:\QtCommercial\QtCommercial5.0.0\Tools\QtCreator\bin\jom.exe" 
    C:\QtCommercial\QtCommercial5.0.0\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"..\..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include" -I"..\..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include\QtWidgets" -I"..\..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include\QtGui" -I"..\..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\include\QtCore" -I"debug" -I"." -I"." -I"..\..\..\..\..\QtCommercial\QtCommercial5.0.0\5.0.0\msvc2010\mkspecs\win32-msvc2010" -Fodebug\ @C:\Users\Scott\AppData\Local\Temp\cookbook.obj.5244.0.jom
cookbook.cpp
..\eCookBook2\cookbook.cpp(34) : warning C4100: 'arg1' : unreferenced formal parameter
    echo 1 /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ 24 /* RT_MANIFEST */ "debug\\eCookBook2.exe.embed.manifest">debug\eCookBook2.exe_manifest.rc
    if not exist debug\eCookBook2.exe del debug\eCookBook2.exe.embed.manifest>NUL 2>&1
    if exist debug\eCookBook2.exe.embed.manifest copy /Y debug\eCookBook2.exe.embed.manifest debug\eCookBook2.exe_manifest.bak
    link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST /MANIFESTFILE:debug\eCookBook2.exe.embed.manifest /OUT:debug\eCookBook2.exe @C:\Users\Scott\AppData\Local\Temp\eCookBook2.exe.5244.2012.jom
cookbook.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QWebView::QWebView(class QWidget *)" (__imp_??0QWebView@@QAE@PAVQWidget@@@Z) referenced in function "public: void __thiscall Ui_cookBook::setupUi(class QMainWindow *)" (?setupUi@Ui_cookBook@@QAEXPAVQMainWindow@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall QWebView::metaObject(void)const " (?metaObject@QWebView@@UBEPBUQMetaObject@@XZ)
cookbook.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall QWebView::qt_metacast(char const *)" (?qt_metacast@QWebView@@UAEPAXPBD@Z)
cookbook.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall QWebView::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@QWebView@@UAEHW4Call@QMetaObject@@HPAPAX@Z)
cookbook.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall QWebView::event(class QEvent *)" (?event@QWebView@@UAE_NPAVQEvent@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "public: virtual class QSize __thiscall QWebView::sizeHint(void)const " (?sizeHint@QWebView@@UBE?AVQSize@@XZ)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::mousePressEvent(class QMouseEvent *)" (?mousePressEvent@QWebView@@MAEXPAVQMouseEvent@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::mouseReleaseEvent(class QMouseEvent *)" (?mouseReleaseEvent@QWebView@@MAEXPAVQMouseEvent@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::mouseDoubleClickEvent(class QMouseEvent *)" (?mouseDoubleClickEvent@QWebView@@MAEXPAVQMouseEvent@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::mouseMoveEvent(class QMouseEvent *)" (?mouseMoveEvent@QWebView@@MAEXPAVQMouseEvent@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::wheelEvent(class QWheelEvent *)" (?wheelEvent@QWebView@@MAEXPAVQWheelEvent@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::keyPressEvent(class QKeyEvent *)" (?keyPressEvent@QWebView@@MAEXPAVQKeyEvent@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::keyReleaseEvent(class QKeyEvent *)" (?keyReleaseEvent@QWebView@@MAEXPAVQKeyEvent@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::focusInEvent(class QFocusEvent *)" (?focusInEvent@QWebView@@MAEXPAVQFocusEvent@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::focusOutEvent(class QFocusEvent *)" (?focusOutEvent@QWebView@@MAEXPAVQFocusEvent@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::paintEvent(class QPaintEvent *)" (?paintEvent@QWebView@@MAEXPAVQPaintEvent@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::resizeEvent(class QResizeEvent *)" (?resizeEvent@QWebView@@MAEXPAVQResizeEvent@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::contextMenuEvent(class QContextMenuEvent *)" (?contextMenuEvent@QWebView@@MAEXPAVQContextMenuEvent@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::dragEnterEvent(class QDragEnterEvent *)" (?dragEnterEvent@QWebView@@MAEXPAVQDragEnterEvent@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::dragMoveEvent(class QDragMoveEvent *)" (?dragMoveEvent@QWebView@@MAEXPAVQDragMoveEvent@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::dragLeaveEvent(class QDragLeaveEvent *)" (?dragLeaveEvent@QWebView@@MAEXPAVQDragLeaveEvent@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::dropEvent(class QDropEvent *)" (?dropEvent@QWebView@@MAEXPAVQDropEvent@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::changeEvent(class QEvent *)" (?changeEvent@QWebView@@MAEXPAVQEvent@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QWebView::inputMethodEvent(class QInputMethodEvent *)" (?inputMethodEvent@QWebView@@MAEXPAVQInputMethodEvent@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "public: virtual class QVariant __thiscall QWebView::inputMethodQuery(enum Qt::InputMethodQuery)const " (?inputMethodQuery@QWebView@@UBE?AVQVariant@@W4InputMethodQuery@Qt@@@Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual bool __thiscall QWebView::focusNextPrevChild(bool)" (?focusNextPrevChild@QWebView@@MAE_N_N@Z)
cookbook.obj : error LNK2001: unresolved external symbol "protected: virtual class QWebView * __thiscall QWebView::createWindow(enum QWebPage::WebWindowType)" (?createWindow@QWebView@@MAEPAV1@W4WebWindowType@QWebPage@@@Z)
cookbook.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QWebView::~QWebView(void)" (__imp_??1QWebView@@UAE@XZ) referenced in function "public: virtual void * __thiscall QWebView::`scalar deleting destructor'(unsigned int)" (??_GQWebView@@UAEPAXI@Z)
cookbook.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QWebView::load(class QUrl const &)" (__imp_?load@QWebView@@QAEXABVQUrl@@@Z) referenced in function "private: void __thiscall cookBook::on_pushButton_clicked(void)" (?on_pushButton_clicked@cookBook@@AAEXXZ)
debug\eCookBook2.exe : fatal error LNK1120: 29 unresolved externals
jom: C:\Users\Scott\Desktop\eCookBook\eCookBook2-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Debug\Makefile.Debug [debug\eCookBook2.exe] Error 1120
jom: C:\Users\Scott\Desktop\eCookBook\eCookBook2-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Debug\Makefile [debug] Error 2
15:05:01: The process "C:\QtCommercial\QtCommercial5.0.0\Tools\QtCreator\bin\jom.exe" exited with code 2.
Error while building/deploying project eCookBook2 (kit: Desktop Qt 5.0.0 MSVC2010 32bit (SDK))
When executing step 'Make'
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-01-29 23:11:04

首先尝试“运行qmake”(在Creator的“构建”菜单中)重新生成make文件,然后重新构建。基本上,每次在.pro文件中进行修改后,您都需要"Run qmake“。

票数 18
EN

Stack Overflow用户

发布于 2016-09-01 21:31:34

修复了相同的错误。尝试在include like中添加到qwebview.h的路径:(将"QtWebKitWidgets“改为您的)

#include <QtWebKitWidgets/QWebView.h>

而不仅仅是#include <QWebView.h>

尝试将其添加到所有使用QWebView的文件中。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14553492

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档