I am a beginner. I am creating a web browser with Qt and webkit (simply added a webview). I am using the latest version of Ubuntu.
The problem is after builidng the browser, when I open websites there are not working all CSS3, HTML5 effects (ie: when I open Google maps then it shows "the simplified version" as because the browser is "outdated").
When I try to access the same pages with chrome or firefox all works well. What could be the problem? I read that I can update the webkit of Qt, but how?
EDIT
What is my software: a simple webview dragged to the mainwindow which opens a website. Website's CSS3 and HTML 5 are not rendered properly
Thanks a lot!
It looks like Google uses the user agent to decide whether your browser supports CSS3 features. You can override the default user agent to make your QWebView appear to Google like a Firefox instance, for example.
You need to subclass QWebPage and override the userAgentForUrl
method:
class WebPage : public QWebPage
{
public:
WebPage(QObject* parent = 0) : QWebPage(parent){}
QString userAgentForUrl(const QUrl &url) const
{
return "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0";
}
};
You then set this subclass into your QWebView:
WebPage* webPage = new WebPage(this);
ui->webView->setPage(webPage);
ui->webView->load(QUrl("http://maps.google.com/"));