0

In my project I have to subclass QWebView to allow for pop-ups. The thing is, I have absolutely no clue how to subclass QWebView. I tried creating a new header file like this:

#ifndef WEB_H
#define WEB_H

#include <QWebView>

class web : public QWebView
{
    Q_OBJECT

    QWebView *web::createWindow(QWebPage::WebWindowType type)
    {
        Q_UNUSED(type);

        QWebView *webView = new QWebView;
        QWebPage *newWeb = new QWebPage(webView);
        webView->setAttribute(Qt::WA_DeleteOnClose, true);
        webView->setPage(newWeb);
        webView->show();

        return webView;
    }

public:
    explicit web(QWidget *parent = 0);

signals:

public slots:

};

#endif // WEB_H

However my WebView won't open any pop-ups.

What is the easiest way to subclass QWebView to allow for the createWindow function?

Thanks for your time :)

4

0 回答 0