我正在使用/示例/activeqt/webbrowser中的qt内置示例,我正在尝试使用documentComplete信号。我的目的是在DocumentComplete之后使用QaxWidget内部的嵌入式Internet Explorer和弹出消息(网站上的Contetnt)。NavigateComplete信号对我来说还不够好...
可以在此处看到代码:QT Web浏览器示例
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(const QString &address);
void on_WebBrowser_DocumentComplete(IDispatch*,QVariant&)
void on_actionGo_triggered();
void on_actionNewWindow_triggered();
void on_actionAddBookmark_triggered();
void on_actionAbout_triggered();
void on_actionAboutQt_triggered();
void on_actionFileClose_triggered();
private:
QProgressBar *m_progressBar;
};
MainWindow::MainWindow()
{
setupUi(this);
connect(m_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()));
connect(WebBrowser,SIGNAL(DocumentComplete(IDispatch*,QVariant&), this, SLOT(on_WebBrowser_DocumentComplete(IDispatch*,QVariant&)))
}
void MainWindow::on_WebBrowser_DocumentComplete(IDispatch*,QVariant&)
{
QMessangeBox x;
x.setText("pop-up");
x.exec();
}
dubbuger说:没有这样的插槽mainwindow :: on_webbrowser_documentComplete(idispatch*,qvariant&)
只要解决方法不仅需要评论:
MyWidgetUsesActiveX::MyWidgetUsesActiveX()
{
///
connect(m_pActiveX, SIGNAL(signal(const QString&, int, void*)),
this, SLOT(activexEventHandler(const QString&, int, void*)));
}
void MyWidgetUsesActiveX::activexEventHandler(
const QString &name, int argc, void *argv)
{
VARIANTARG *params = (VARIANTARG*)argv;
// See what events fired
qDebug() << "Event:" << name << "argc:" << argc;
// some concrete example
if (name == "OnRemoteWindowDisplayed")
{
// Extract parameters
_variant_t varValue = params[argc-1];
bool bDisplayed = (bool)varValue;
// hwnd
varValue = params[argc-2];
int iResult = (int)varValue;
varValue = params[argc-3];
int windowAttribute = (int) varValue;
// CALL that stubborn slot we cannot have called otherwise
onRemoteWindowDisplayed(bDisplayed, iResult, windowAttribute);
}
else if (name == "OnSomethingElse")
{
// extract concrete parameters and call the handler from here
// onSomethingElse(param1, param2, param3);
}
else
{
// Log it?
}
}
i通过再生.moc文件解决了问题。在构建配置下,Qmake的文件夹位置是错误的。通过将其纠正到项目位置解决了我的问题。现在已识别该插槽。谢谢大家的帮助。
QT构建配置