Qt自定义插槽QWebView
我刚刚接触Qt,我正在尝试使用信号和插槽,但在创建自定义插槽时遇到了一些问题:Qt自定义插槽QWebView,qt,signals-slots,qwebview,qwebkit,qpushbutton,Qt,Signals Slots,Qwebview,Qwebkit,Qpushbutton,我刚刚接触Qt,我正在尝试使用信号和插槽,但在创建自定义插槽时遇到了一些问题: public slots: void resetUrl(){ this->load(QUrl("http://www.google.com")); } 然后,在我的main.cpp中 #include <QWebView> #include <QPushButton> QWebView *web = new QWebView(mainwindow);
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()));
这就是我所能得到的一切,任何帮助都将不胜感激。当我试着运行这个时,它说的是“类google”没有名为“load”的成员。我确信你的类没有load函数,你想要的是web->loadurl而不是此->loadurl可能重复的,请不要在不同的线程中发布相同的问题两次。