I use QWebView as template editor in my app.
Structure of my project:
Qt Code:
  1. MyProject/
  2. app.exe
  3. Templates/
  4. style.css
  5. template.html
To copy to clipboard, switch view to plain text mode 
This is simplified HTML code of template:
Qt Code:
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html><head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  4. <link rel="stylesheet" type="text/css" href="style.css" />
  5. </head>
  6. <body>
  7. <p>Some content</p>
  8. </body>
  9. </html>
To copy to clipboard, switch view to plain text mode 
in same directory I have style.css:
Qt Code:
  1. html,body {
  2. font-family:Tahoma;
  3. }
To copy to clipboard, switch view to plain text mode 
But QWebView ignores my styles. I guess it just can't load it.
Code for content loading:
Qt Code:
  1. QFile file(QApplication::applicationDirPath() + "/Templates/template.html");
  2. QUrl url(QApplication::applicationDirPath() + "/Templates");
  3. ui->textEdit->setHtml(file.readAll(),url);
To copy to clipboard, switch view to plain text mode 
I tried
Qt Code:
  1. ui->textEdit->settings()->setUserStyleSheetUrl(url);
To copy to clipboard, switch view to plain text mode 
and
Qt Code:
  1. QUrl url("file://" + QApplication::applicationDirPath() + "/Templates");
To copy to clipboard, switch view to plain text mode 
but nothing helps.
So how can I load local css file to QWebView?