2013-08-23 102 views
-2

我是相當新的Qt和我試圖用信號和槽的工作,我有一點麻煩創建自定義插槽:Qt的自定義插槽QWebView

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'的成員「。

+0

可能重複http://stackoverflow.com/questions/18394950/qt-c-custom -slot) – thuga

+0

請不要在不同的線程中發佈兩次相同的問題。 – lpapp

回答

0

我敢肯定你的類沒有加載功能,你想不web->load(url)this->load(url)

[Qt的C++自定義插槽(的