首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用QAxWidget在qt中记录完成的信号

使用QAxWidget在qt中记录完成的信号
EN

Stack Overflow用户
提问于 2017-12-27 15:14:54
回答 2查看 402关注 0票数 0

我在/ Examples /activeqt/webbrowser中使用了qt内置示例,并尝试使用DocumentComplete SIGNAL。我的目的是在QAxWidget中使用嵌入式Internet explorer,并在DocumentComplete之后弹出一条消息(内容来自网站)。NavigateComplete信号不够好,不适合我使用...

代码可以在这里看到:qt Web browser Example

代码语言:javascript
运行
复制
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();
}

配音员说:没有这样的槽MainWindow::on_WebBrowser_DocumentComplete(IDispatch*,QVaria‌​nt&)

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-12-31 14:34:57

我通过重新生成.moc文件解决了这个问题。在构建配置下,qmake的文件夹位置是错误的。通过将其更正为项目位置,修复了我的问题。现在可以识别该插槽。感谢大家的帮助。

Qt Build Configuration

票数 0
EN

Stack Overflow用户

发布于 2017-12-29 00:53:48

只要解决方法需要的不仅仅是注释:

代码语言:javascript
运行
复制
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?
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47987953

复制
相关文章

相似问题

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