Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How do setSource() and setSearchPaths() in QTextBrowser work together?
One function takes a
QUrlobject as parameter, the other a
QStringList. The documentation says this about the
"When setting this property QTextBrowser tries to find a document with the specified name in the paths of the searchPaths property and directory of the current source, unless the value is an absolute file path. It also checks for optional anchors and scrolls the document accordingly."
I have some HTML files embedded in the Qt resource file. I have defined virtual folders "/help" and "help/images". So when I load the HTML file and write:
it works. However, if I set
"qrc:/help/images", then write:
it cannot find the file. I haven't tried any images yet, because I do not know how I am supposed to do this. There will eventually be more paths depending on languages.
@robert-hairgrove I guess setSearchPaths() only works for file system, not resources.
In the meantime, I tried loading a page with one image. As long as I include the subdirectory in the image
srctag, it is found, even without setting
searchPathsat all. The image and the HTML page are actually in the same physical
qrcfolder (as required by Qt, at least -- actually I am putting symlinks to the real files there so that I have a little more organization in my work). So it appears that the virtual folders defined in the resources are found OK.
Then the question remains: What can
searchPathsdo for me? Does someone have an example?
searchPaths() is using QFileInfo(foo).isReadable() - I would check what this gives for you to see if maybe QFileInfo can't handle qrc urls.
@christian-ehrlicher Thanks for this useful link. Perhaps I should use the
":/"scheme when setting
":/"before doing the actual search. I will try this.