Created
January 2, 2012 11:29
-
-
Save R4md4c/1550351 to your computer and use it in GitHub Desktop.
MainWindow of the program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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() | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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