我正在尝试使用 VS2010((我在 windows7 x64 上工作)重现 Qt 示例“webbrowser”(来自 qt-everywhere-opensource-src-4.8.3/examples/activeqt/webbrwowser)。
所以,我将所有文件(.h 和 .cpp)从 webbrowser 文件夹复制到我的项目中。此外,在项目属性-->链接器-->输入-->附加指令中,我添加了以下库:
phonon4.lib
QAxServer.lib
Qt3Support4.lib
QtCLucene4.lib
QtCore4.lib
QtDeclarative4.lib
QtDesigner4.lib
QtDesignerComponents4.lib
QtGui4.lib
QtHelp4.lib
Qtmain.lib
QtMultimedia4.lib
QtNetwork4.lib
QtOpenGL4.lib
QtScript4.lib
QtScriptTools4.lib
QtSql4.lib
QtSvg4.lib
QtTest4.lib
QtUiTools.lib
QtWebKit4.lib
QtXml4.lib
QtXmlPatterns4.lib
现在,当我按下调试按钮时,我得到了这些错误:
1>------ Inizio compilazione: Progetto: web_browser, Configurazione: Debug Win32 ------
1> main.cpp
1>main.obj : error LNK2019: riferimento al simbolo esterno "public: class QVariant __thiscall QAxBase::dynamicCall(char const *,class QVariant const &,class QVariant const &,class QVariant const &,class QVariant const &,class QVariant const &,class QVariant const &,class QVariant const &,class QVariant const &)" (?dynamicCall@QAxBase@@QAE?AVQVariant@@PBDABV2@1111111@Z) non risolto nella funzione "public: __thiscall MainWindow::MainWindow(void)" (??0MainWindow@@QAE@XZ)
1>main.obj : error LNK2019: riferimento al simbolo esterno "public: bool __thiscall QAxBase::setControl(class QString const &)" (?setControl@QAxBase@@QAE_NABVQString@@@Z) non risolto nella funzione "public: void __thiscall Ui_MainWindow::setupUi(class QMainWindow *)" (?setupUi@Ui_MainWindow@@QAEXPAVQMainWindow@@@Z)
1>main.obj : error LNK2019: riferimento al simbolo esterno "public: __thiscall QAxWidget::QAxWidget(class QWidget *,class QFlags<enum Qt::WindowType>)" (??0QAxWidget@@QAE@PAVQWidget@@V?$QFlags@W4WindowType@Qt@@@@@Z) non risolto nella funzione "public: __thiscall WebAxWidget::WebAxWidget(class QWidget *,class QFlags<enum Qt::WindowType>)" (??0WebAxWidget@@QAE@PAVQWidget@@V?$QFlags@W4WindowType@Qt@@@@@Z)
1>main.obj : error LNK2001: simbolo esterno "public: virtual struct QMetaObject const * __thiscall QAxWidget::metaObject(void)const " (?metaObject@QAxWidget@@UBEPBUQMetaObject@@XZ) non risolto
1>main.obj : error LNK2001: simbolo esterno "public: virtual void * __thiscall QAxWidget::qt_metacast(char const *)" (?qt_metacast@QAxWidget@@UAEPAXPBD@Z) non risolto
1>main.obj : error LNK2001: simbolo esterno "public: virtual int __thiscall QAxWidget::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@QAxWidget@@UAEHW4Call@QMetaObject@@HPAPAX@Z) non risolto
1>main.obj : error LNK2001: simbolo esterno "protected: virtual void __thiscall QAxWidget::connectNotify(char const *)" (?connectNotify@QAxWidget@@MAEXPBD@Z) non risolto
1>main.obj : error LNK2001: simbolo esterno "public: virtual class QSize __thiscall QAxWidget::sizeHint(void)const " (?sizeHint@QAxWidget@@UBE?AVQSize@@XZ) non risolto
1>main.obj : error LNK2001: simbolo esterno "public: virtual class QSize __thiscall QAxWidget::minimumSizeHint(void)const " (?minimumSizeHint@QAxWidget@@UBE?AVQSize@@XZ) non risolto
1>main.obj : error LNK2001: simbolo esterno "protected: virtual void __thiscall QAxWidget::resizeEvent(class QResizeEvent *)" (?resizeEvent@QAxWidget@@MAEXPAVQResizeEvent@@@Z) non risolto
1>main.obj : error LNK2001: simbolo esterno "protected: virtual void __thiscall QAxWidget::changeEvent(class QEvent *)" (?changeEvent@QAxWidget@@MAEXPAVQEvent@@@Z) non risolto
1>main.obj : error LNK2001: simbolo esterno "public: virtual class QAxAggregated * __thiscall QAxWidget::createAggregate(void)" (?createAggregate@QAxWidget@@UAEPAVQAxAggregated@@XZ) non risolto
1>main.obj : error LNK2001: simbolo esterno "protected: virtual bool __thiscall QAxWidget::createHostWindow(bool)" (?createHostWindow@QAxWidget@@MAE_N_N@Z) non risolto
1>main.obj : error LNK2001: simbolo esterno "public: virtual char const * __thiscall QAxWidget::className(void)const " (?className@QAxWidget@@UBEPBDXZ) non risolto
1>main.obj : error LNK2001: simbolo esterno "public: virtual bool __thiscall QAxBase::propertyWritable(char const *)const " (?propertyWritable@QAxBase@@UBE_NPBD@Z) non risolto
1>main.obj : error LNK2001: simbolo esterno "public: virtual void __thiscall QAxBase::setPropertyWritable(char const *,bool)" (?setPropertyWritable@QAxBase@@UAEXPBD_N@Z) non risolto
1>main.obj : error LNK2001: simbolo esterno "public: virtual void __thiscall QAxWidget::clear(void)" (?clear@QAxWidget@@UAEXXZ) non risolto
1>main.obj : error LNK2001: simbolo esterno "protected: virtual bool __thiscall QAxWidget::initialize(struct IUnknown * *)" (?initialize@QAxWidget@@MAE_NPAPAUIUnknown@@@Z) non risolto
1>main.obj : error LNK2001: simbolo esterno "private: virtual struct QMetaObject const * __thiscall QAxWidget::parentMetaObject(void)const " (?parentMetaObject@QAxWidget@@EBEPBUQMetaObject@@XZ) non risolto
1>main.obj : error LNK2019: riferimento al simbolo esterno "protected: virtual bool __thiscall QAxWidget::translateKeyEvent(int,int)const " (?translateKeyEvent@QAxWidget@@MBE_NHH@Z) non risolto nella funzione "protected: virtual bool __thiscall WebAxWidget::translateKeyEvent(int,int)const " (?translateKeyEvent@WebAxWidget@@MBE_NHH@Z)
1>main.obj : error LNK2019: riferimento al simbolo esterno "public: virtual __thiscall QAxWidget::~QAxWidget(void)" (??1QAxWidget@@UAE@XZ) non risolto nella funzione "public: virtual __thiscall WebAxWidget::~WebAxWidget(void)" (??1WebAxWidget@@UAE@XZ)
1>C:\Users\Cristina\Desktop\OpenCV\Progetti\ARUCO\web_browser\Debug\web_browser.exe : fatal error LNK1120: 21 esterni non risolti
========== Compilazione: 0 completate, 1 non riuscite, 0 aggiornate, 0 ignorate ==========
这是 main.cpp 文件:
#include <C:/Users/Cristina/Desktop/OpenCV/dep/qt/qt-everywhere-opensource-src-4.8.3/include/QtGui/qapplication.h>
#include <C:/Users/Cristina/Desktop/OpenCV/dep/qt/qt-everywhere-opensource-src-4.8.3/include/QtGui/QMessageBox>
#include <C:/Users/Cristina/Desktop/OpenCV/dep/qt/qt-everywhere-opensource-src-4.8.3/include/QtGui/QProgressBar>
#include <C:/Users/Cristina/Desktop/OpenCV/dep/qt/qt-everywhere-opensource-src-4.8.3/include/QtGui/QStatusBar>
#include <C:/Users/Cristina/Desktop/OpenCV/dep/qt/qt-everywhere-opensource-src-4.8.3/include/QtGui/QMainWindow>
#include <C:/Users/Cristina/Desktop/OpenCV/dep/qt/qt-everywhere-opensource-src-4.8.3/include/QtCore/QAbstractEventDispatcher>
#if defined(Q_WS_WINCE_WM)
#include "ui_mainwindow_windowsmobile.h"
#include <windows.h>
#else
#include "ui_mainwindow.h"
#endif
//! [0]
class MainWindow : public QMainWindow, public Ui::MainWindow
{
Q_OBJECT
public:
MainWindow();
public slots:
void on_WebBrowser_TitleChange(const QString &title);
void on_WebBrowser_ProgressChange(int a, int b);
void on_WebBrowser_CommandStateChange(int cmd, bool on);
void on_WebBrowser_BeforeNavigate();
void on_WebBrowser_NavigateComplete(QString);
void on_actionGo_triggered();
void on_actionNewWindow_triggered();
void on_actionAbout_triggered();
void on_actionAboutQt_triggered();
void on_actionFileClose_triggered();
private:
QProgressBar *pb;
};
//! [0] //! [1]
MainWindow::MainWindow()
{
setupUi(this);
connect(addressEdit, SIGNAL(returnPressed()), actionGo, SLOT(trigger()));
connect(actionBack, SIGNAL(triggered()), WebBrowser, SLOT(GoBack()));
connect(actionForward, SIGNAL(triggered()), WebBrowser, SLOT(GoForward()));
connect(actionStop, SIGNAL(triggered()), WebBrowser, SLOT(Stop()));
connect(actionRefresh, SIGNAL(triggered()), WebBrowser, SLOT(Refresh()));
connect(actionHome, SIGNAL(triggered()), WebBrowser, SLOT(GoHome()));
connect(actionSearch, SIGNAL(triggered()), WebBrowser, SLOT(GoSearch()));
pb = new QProgressBar(statusBar());
pb->setTextVisible(false);
pb->hide();
statusBar()->addPermanentWidget(pb);
WebBrowser->dynamicCall("GoHome()");
}
//! [1] //! [2]
void MainWindow::on_WebBrowser_TitleChange(const QString &title)
{
setWindowTitle("Qt WebBrowser - " + title);
}
void MainWindow::on_WebBrowser_ProgressChange(int a, int b)
{
if (a <= 0 || b <= 0) {
pb->hide();
return;
}
pb->show();
pb->setRange(0, b);
pb->setValue(a);
}
void MainWindow::on_WebBrowser_CommandStateChange(int cmd, bool on)
{
switch (cmd) {
case 1:
actionForward->setEnabled(on);
break;
case 2:
actionBack->setEnabled(on);
break;
}
}
void MainWindow::on_WebBrowser_BeforeNavigate()
{
actionStop->setEnabled(true);
}
void MainWindow::on_WebBrowser_NavigateComplete(QString)
{
actionStop->setEnabled(false);
}
//! [2] //! [3]
void MainWindow::on_actionGo_triggered()
{
WebBrowser->dynamicCall("Navigate(const QString&)", addressEdit->text());
}
void MainWindow::on_actionNewWindow_triggered()
{
MainWindow *window = new MainWindow;
window->show();
if (addressEdit->text().isEmpty())
return;
window->addressEdit->setText(addressEdit->text());
window->actionStop->setEnabled(true);
window->on_actionGo_triggered();
}
void MainWindow::on_actionAbout_triggered()
{
QMessageBox::about(this, tr("About WebBrowser"),
tr("This Example has been created using the ActiveQt integration into Qt Designer./n"
"It demonstrates the use of QAxWidget to embed the Internet Explorer ActiveX/n"
"control into a Qt application."));
}
void MainWindow::on_actionAboutQt_triggered()
{
QMessageBox::aboutQt(this, tr("About Qt"));
}
void MainWindow::on_actionFileClose_triggered()
{
close();
}
#include "C:/Users/Cristina/Desktop/OpenCV/dep/qt/qt-everywhere-opensource-src-4.8.3/examples/activeqt/webbrowser/tmp/moc/debug_shared/main.moc"
//! [3] //! [4]
int main(int argc, char ** argv)
{
QApplication a(argc, argv);
MainWindow w;
#if defined(Q_OS_WINCE)
w.showMaximized();
#else
w.show();
#endif
return a.exec();
}
//! [4]
我哪里错了??谢谢你的帮助!