Skip to content

Instantly share code, notes, and snippets.

@R4md4c
Created January 2, 2012 11:29
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 R4md4c/1550351 to your computer and use it in GitHub Desktop.
Save R4md4c/1550351 to your computer and use it in GitHub Desktop.
MainWindow of the program
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtWebKit/QWebView>
#include <QUrl>
#include <QDesktopServices>
#include <QMessageBox>
MainWindow::MainWindow(const QUrl& urlToOpen, QWidget *parent) :
QWebView(parent)
{
load(urlToOpen);
QWebSettings::setIconDatabasePath(QDesktopServices::storageLocation(QDesktopServices::ApplicationsLocation));
connect(this, SIGNAL(titleChanged(QString)), SLOT(onTitleChanged(QString)));
connect(this, SIGNAL(iconChanged()), SLOT(onIconChanged()));
connect(this, SIGNAL(loadFinished(bool)), SLOT(onLoadPageFinished(bool)));
}
void MainWindow::onTitleChanged(const QString& title)
{
setWindowTitle(title);
}
void MainWindow::onIconChanged()
{
setWindowIcon(icon());
}
void MainWindow::onLoadPageFinished(bool isLoadFinished)
{
setWindowIcon(icon());
if(isLoadFinished)
QMessageBox::information(this, "Load Finished", "Page is Loaded Successfully", QMessageBox::Ok);
else
QMessageBox::information(this, "Load Finished", "Page Loading Timeout", QMessageBox::Ok);
}
MainWindow::~MainWindow()
{
}
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QWebView>
class QUrl;
class MainWindow : public QWebView
{
Q_OBJECT
public:
explicit MainWindow(const QUrl& urlToOpen, QWidget *parent = 0);
~MainWindow();
private:
QWebView *m_webView;
private slots:
void onTitleChanged(const QString&);
void onIconChanged();
void onLoadPageFinished(bool);
};
#endif // MAINWINDOW_H
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment