Tuesday, December 31, 2013

Qt Tips

Recently I have been developing with Qt. I don't want to waste the value of my time spent on searching for solutions to those problems, so recording all my quesitons will be much consoling.

1. QWebView loads html from resource
As you can search on the Net, many peole write codes like
webView->setUrl(QUrl::fromLocalFile(":/html/homepage.html"));
But it won't work. Using qDebug() to output its url, the only thing you can get is "about:blank". You should write like this:
webView->setUrl(QUrl("qrc:///html/homepage.html"));

P.S. To get your resource path, just open the resource editor in Qt creator, right-click on the target resource and choose "Copy Resource Path to clipboard".


to be continued...

No comments:

Post a Comment