Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #include <QtGui>
  2. #include <QtWebKit>
  3. #include <QLabel>
  4.  
  5. class WebView : public QWebView {
  6. public:
  7. WebView() : QWebView(0) {
  8.  
  9. QFontDatabase fontDb;
  10.  
  11. qDebug() << "installd fonts are:";
  12. foreach (const QString &family, fontDb.families()) {
  13. qDebug() << family;
  14. }
  15. qDebug() << "";
  16.  
  17. QWebSettings *defaultSettings = QWebSettings::globalSettings();
  18.  
  19.  
  20. QString fontName(QLatin1String("/home/test/Desktop/fonts/Arial.ttf"));
  21. int appFontId = QFontDatabase::addApplicationFont(fontName);
  22.  
  23. if (appFontId < 0){
  24. qWarning() << "Attempt to load application font: "<< fontName << " failed.";
  25. } else {
  26. qDebug() << "appFontId = " << appFontId;
  27. }
  28.  
  29. foreach (const QString &family, fontDb.families()) {
  30. qDebug() << family;
  31. }
  32. qDebug() << "";
  33.  
  34. defaultSettings->setFontFamily(QWebSettings::StandardFont, "Arial");
  35.  
  36. load(QUrl("file:///home/test/Desktop/main.html"));
  37. resize(750, 400);
  38. }
  39.  
  40. };
  41.  
  42. int main(int argc, char *argv[]) {
  43. QApplication app(argc, argv);
  44.  
  45. WebView view;
  46. view.show();
  47. view.showFullScreen();
  48.  
  49. return app.exec();
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement