Skip to content

Instantly share code, notes, and snippets.

@speakman
Created August 23, 2012 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save speakman/3436685 to your computer and use it in GitHub Desktop.
Save speakman/3436685 to your computer and use it in GitHub Desktop.
Qt Simple Browser
#include <QApplication>
#include <QWebView>
#include <QWebPage>
#include <QUrl>
QNetworkAccessManager nam;
class WebPage : public QWebPage
{
public:
WebPage(QObject *parent = 0) : QWebPage(parent)
{
setNetworkAccessManager(&nam);
}
QWebPage *createWindow(QWebPage::WebWindowType type)
{
QWebView *wv = new QWebView;
if (type == QWebPage::WebModalDialog)
wv->setWindowModality(Qt::ApplicationModal);
return wv->page();
}
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWebView view;
QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
view.setPage(new WebPage);
view.load(QUrl("http://help.dottoro.com/external/examples/ljdlgxbu/showModalDialog_1.htm"));
view.show();
return a.exec();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment