Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <QtGui>
- #include <QtWebKit>
- #include <QLabel>
- class WebView : public QWebView {
- public:
- WebView() : QWebView(0) {
- QFontDatabase fontDb;
- qDebug() << "installd fonts are:";
- foreach (const QString &family, fontDb.families()) {
- qDebug() << family;
- }
- qDebug() << "";
- QWebSettings *defaultSettings = QWebSettings::globalSettings();
- QString fontName(QLatin1String("/home/test/Desktop/fonts/Arial.ttf"));
- int appFontId = QFontDatabase::addApplicationFont(fontName);
- if (appFontId < 0){
- qWarning() << "Attempt to load application font: "<< fontName << " failed.";
- } else {
- qDebug() << "appFontId = " << appFontId;
- }
- foreach (const QString &family, fontDb.families()) {
- qDebug() << family;
- }
- qDebug() << "";
- defaultSettings->setFontFamily(QWebSettings::StandardFont, "Arial");
- load(QUrl("file:///home/test/Desktop/main.html"));
- resize(750, 400);
- }
- };
- int main(int argc, char *argv[]) {
- QApplication app(argc, argv);
- WebView view;
- view.show();
- view.showFullScreen();
- return app.exec();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement