How to set QWebView content from QHelpEngineCore to enable CSS links?
-
I don't think I'm understanding you well.
I know where to find the plugins (and they are there), but do I need to put the dlls in my debug/release map or in my main projects folder? e.g. myapplication\debug\plugins\imageformats... or myapplication\plugins\imageformats...
It's a pitty you can't debug assistant, cause that is almost what i need. What it displays.
But it doens't seem to work in my QWebview. -
The idea with the plugins was just a guess. I think enabling the "QWebInspector":http://qt-project.org/doc/qt-4.8/qwebinspector.html is the first thing you should try.
-
And how can I use that? I never worked with QWebview (apart from this subject), let alone that I worked with QWebInspector.
I've tried to put create a QWebPage like:
@QWebPage *page = ui->webView->page();@
and a QWebinspector like so:
@QWebInspector *inspector = new QWebInspector;@when i try to set my page, nothing happens, my QWebPage is empty...
-
I haven't used the WebInspector myself but the documentation of it is pretty much selfexplanatory. After you have set the Html content for your WebView, you just need to get the WebPage pointer from the WebView, create the WebInspector and set the page for the WebInspector.
@
ui->yourWebView->setHtml(yourContent, yourBaseUrl);
QWebInspector *inspector = new QWebInspector(ui->yourWebView);
inspector->setPage(ui->yourWebView->page());
inspector->setVisible();
@
If this is not working, maybe you also need to set some settings to make it work (QWebSettings::DeveloperExtrasEnabled). Have a look at "QWebSettings":https://qt-project.org/doc/qt-4.8/qwebsettings.html this class also has a function called setUserStyleSheetUrl(..). -
Sorry if I have to bother you again:s
But nothing is happening. Even not showing the inspector anymore.And this is what i'm trying to do:
@QString myHtmlContent = QString(m_helpEngine->fileData(url));
QUrl myBaseUrl = QUrl("qthelp://com.mynamespace/doc");
if(!myHtmlContent.isEmpty())
{
// ui->webView->setContent(helpData, QString(), myBaseUrl);
ui->webView->setHtml(myHtmlContent, myBaseUrl);
}//QWebPage *page = ;
ui->webView->page()->settings()->DeveloperExtrasEnabled;
QWebInspector *inspector = new QWebInspector(ui->webView);
inspector->setPage(ui->webView->page());
inspector->setVisible(true);@[EDIT] It works: @ui->webView->page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);@
-
Do the style sheets and images also work now ?
-
Ok now that I got that, nothing seems to be loaded. No images, no stylesheets...
-
!http://wouterverbruggen.be/img/outcome.jpg(outcome)!
As you can see, no content is loaded (i think)
-
Maybe you can first test with a local Html file ,Css file and image and get that working and then proceed with the qHelp Urls. Just to pinpoint the error source.
Edit: Have you checked the QString holding the Html content?
-
That indeed could be a good idea, i'll keep you posted
-
With local files it works fine, it shows my pictures and the css i made.
I have checked the QString, it's filled with the code I programmed and stored in the QHelpEngine.
Could there be something wrong with my qch, qhc, qhcp or qhp files?I took as example the code from "Using Qt Assistant as a Custom Help Viewer":http://doc.qt.nokia.com/4.7-snapshot/assistant-custom-help-viewer.html
But I don't know if that was the best idea -
I'm really sorry but I have no experience in using the QHelpEngine and thus am unable to help you with anything related to this component. I fear the problem is that the qHelp Urls can not be used with Html, but this is just a guess. Is there maybe another way to display the help files other then using QWebkit?
-
No problem, maybe I better open a new topic to bring this thing up:) But thanks for the help! You did a great job helping me understand some handy tools ;)
There is a way, using Assistant, but the problem is that user can browse there (even when you turn this function off). We don't want them to browse, but to only view the pages that are related to the topic.