【问题标题】:Qt Custom Slot QWebViewQt 自定义插槽 QWebView
【发布时间】:2013-08-23 04:06:32
【问题描述】:

我是 Qt 的新手,我正在尝试使用信号和插槽,但在创建自定义插槽时遇到了一些麻烦:

public slots:
    void resetUrl(){
        this->load(QUrl("http://www.google.com"));
    }

(然后,在我的 main.cpp 中)

#include <QWebView>
#include <QPushButton>

QWebView *web = new QWebView(mainwindow);
QPushButton *button = new QPushButton(mainwindow);

web->load(QUrl("http://www.yahoo.com"));
button->setText("Google");

QObject::connect(button, SIGNAL(clicked()), web, SLOT(resetUrl()));

这就是我得到的一切,感谢任何帮助。当我尝试运行它时它说的是“'class google'没有名为'load'的成员”。

【问题讨论】:

  • Qt C++ Custom Slot的可能重复
  • 请不要在不同的线程中两次发布相同的问题。

标签: qt signals-slots qwebview qwebkit qpushbutton


【解决方案1】:

我确定你的类没有加载功能,你想要web-&gt;load(url)而不是this-&gt;load(url)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-10
    • 1970-01-01
    • 2010-11-11
    • 2012-11-21
    • 2020-06-29
    相关资源
    最近更新 更多