64-bit Qt Assistant does not recognize external css
-
wrote on 30 Aug 2023, 14:37 last edited by JHerman
A project I've been working on was recently updated from 32-bit Qt to 64-bit, and the Qt Help Project paired with it stopped recognizing its external css file around this time.
I've been trying to troubleshoot why it isn't recognizing the file, and made a small test project to work through things. I found that if I run Qt Assistant on this test project using a 64-bit version, the css fails, but if I run everything through 32-bit using the exact same files, the css works.
I followed the documentation for Qt Help Project and Qt Assistant, and put together test .qhp and .qhcp files.
.qhp:
<?xml version="1.0" encoding="UTF-8" ?> <QtHelpProject version="1.0"> <namespace>testcompany.com.testhelp.1.0</namespace> <virtualFolder>doc</virtualFolder> <customFilter name="Test Help 1.0"> <filterAttribute>testhelp</filterAttribute> <filterAttribute>1.0</filterAttribute> </customFilter> <filterSection> <filterAttribute>testhelp</filterAttribute> <filterAttribute>1.0</filterAttribute> <toc> <section title="Test Help Manual" ref="testproject.html"></section> </toc> <keywords> <keyword name="testproject" ref="testproject.html" /> </keywords> <files> <file>testproject.css</file> <file>testproject.html</file> </files> </filterSection> </QtHelpProject>
.qhcp:
<?xml version="1.0" encoding="utf-8" ?> <QHelpCollectionProject version="1.0"> <assistant> <title>Test Help</title> <enableFilterFunctionality>false</enableFilterFunctionality> <enableDocumentationManager>false</enableDocumentationManager> <enableAddressBar visible="true">true</enableAddressBar> <cacheDirectory>TestCompany/TestHelp</cacheDirectory> <aboutMenuText> <text>About Test Help</text> </aboutMenuText> </assistant> <docFiles> <generate> <file> <input>test.qhp</input> <output>test.qch</output> </file> </generate> <register> <file>test.qch</file> </register> </docFiles> </QHelpCollectionProject>
The html and css files I'm using are very simple, just a single heading element and a single paragraph element, and then css to color/resize them in the .css file.
html:
<?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Test Project</title> <link rel="StyleSheet" href="testproject.css" type="text/css" /> </head> <body> <h1>Test Help Project</h1> <p> This is a test project to see if I can get css working with Qt Assistant </p> </body> </html>
css:
H1 { color: #00ff00; background-color: #0000ff; font-size: 28pt; } p { color: #ff0000; font-size: 15pt; }
This is what the page looks like when run through 64-bit:
And this is what it looks like through 32-bit:
I've searched through the documentation for Qt Help and Qt Assistant, and from what I can tell, what I have should work just fine. Does anyone know if there's something I'm missing to get the css to work?
-
Hi and welcome to devnet,
Might be a silly question but are you sure all the files are found at run time by the 64 bit executable ?
-
Hi and welcome to devnet,
Might be a silly question but are you sure all the files are found at run time by the 64 bit executable ?
wrote on 30 Aug 2023, 19:23 last edited by@SGaist
I guess I'm not 100% certain, but I don't see why they wouldn't be found by the 64-bit if they were found by the 32-bit executable.Everything is contained and ran in the same directory, including the executable.
Is how the executable searches for files at run time different between 32-bit and 64-bit?
-
@SGaist
I guess I'm not 100% certain, but I don't see why they wouldn't be found by the 64-bit if they were found by the 32-bit executable.Everything is contained and ran in the same directory, including the executable.
Is how the executable searches for files at run time different between 32-bit and 64-bit?
AFAIK they should not especially if the files are in the same folder as your application.
The only thing that comes to mind is the library loading paths.
On which OS are you ? On Linux you could use strace to check what is getting opened and if the css is somehow missed.
-
@SGaist
I guess I'm not 100% certain, but I don't see why they wouldn't be found by the 64-bit if they were found by the 32-bit executable.Everything is contained and ran in the same directory, including the executable.
Is how the executable searches for files at run time different between 32-bit and 64-bit?
wrote on 2 Sept 2023, 04:56 last edited by@JHerman A file opened with a relative path will be looked for in the current working directory of the process. That is not necessarily, or even generally, the same as the location of the executable. Check the the running program's (which I assume is a version of Assistant) current working directory is where you think it is.
-
AFAIK they should not especially if the files are in the same folder as your application.
The only thing that comes to mind is the library loading paths.
On which OS are you ? On Linux you could use strace to check what is getting opened and if the css is somehow missed.
wrote on 3 Jan 2024, 15:58 last edited by@SGaist I had to move away from this issue for a couple months. Looking back at it, the css file is being compressed into the .qch file, so it appears that the Qt Help generation steps are finding it.
From my understanding looking at the documentation, Assistant looks for the files from where they are compressed in the .qch file, so it should be able to find it.
I tried a couple other things like using a -stylesheet parameter when I ran assistant from command line, but they haven't worked either.
-
@SGaist I had to move away from this issue for a couple months. Looking back at it, the css file is being compressed into the .qch file, so it appears that the Qt Help generation steps are finding it.
From my understanding looking at the documentation, Assistant looks for the files from where they are compressed in the .qch file, so it should be able to find it.
I tried a couple other things like using a -stylesheet parameter when I ran assistant from command line, but they haven't worked either.
@JHerman can you provide a minimal compilable project that allows to reproduce that issue ?
-
@JHerman can you provide a minimal compilable project that allows to reproduce that issue ?
wrote on 3 Jan 2024, 21:26 last edited by JHerman 1 Mar 2024, 21:29@SGaist I'm not seeing a way to attach files to the thread, but the code snippets in the original post are the entirety of each of the 4 files I used to compile, the .qhp, the .qhcp, the .html, and the .css files.
Ah, before I forget, I should mention that the OS running these projects are Windows 10/11.
-
@SGaist I'm not seeing a way to attach files to the thread, but the code snippets in the original post are the entirety of each of the 4 files I used to compile, the .qhp, the .qhcp, the .html, and the .css files.
Ah, before I forget, I should mention that the OS running these projects are Windows 10/11.
wrote on 3 Jan 2024, 23:40 last edited by ChrisW67 1 Apr 2024, 02:46@JHerman The
rel
attribute of thelink
element in your HTML is mixed-case "StyleSheet". AFAICT this is acceptable in the HTML living "standard", which defines these as case-insensitive. The HTML works correctly in a browsers.However, a quick experiment with your example files on Linux shows it is broken here too. It only works correctly in the Qt help framework if the
rel
attribute is lower case"stylesheet"
, exactly as presented in the standard's acceptable values list.<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Test Project</title> <link rel="stylesheet" href="testproject.css" type="text/css"/> </head> <body> <h1>Test Help Project</h1> <p> This is a test project to see if I can get css working with Qt Assistant </p> </body> </html>
$ ~/Qt/6.6.1/gcc_64/libexec/qhelpgenerator test.qhcp $ ~/Qt/6.6.1/gcc_64/bin/assistant -collectionFile test.qhc
Whether this is a deliberate choice or a bug in the help generator or help rendering engine I do not know. -
@JHerman The
rel
attribute of thelink
element in your HTML is mixed-case "StyleSheet". AFAICT this is acceptable in the HTML living "standard", which defines these as case-insensitive. The HTML works correctly in a browsers.However, a quick experiment with your example files on Linux shows it is broken here too. It only works correctly in the Qt help framework if the
rel
attribute is lower case"stylesheet"
, exactly as presented in the standard's acceptable values list.<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Test Project</title> <link rel="stylesheet" href="testproject.css" type="text/css"/> </head> <body> <h1>Test Help Project</h1> <p> This is a test project to see if I can get css working with Qt Assistant </p> </body> </html>
$ ~/Qt/6.6.1/gcc_64/libexec/qhelpgenerator test.qhcp $ ~/Qt/6.6.1/gcc_64/bin/assistant -collectionFile test.qhc
Whether this is a deliberate choice or a bug in the help generator or help rendering engine I do not know.wrote on 4 Jan 2024, 14:58 last edited by@ChrisW67 Tried this out for myself. This was the problem all along it seems. Looks like Qt either made Assistant more strict with HTML standards in newer versions or this was a bug introduced somewhere, because "StyleSheet" worked just fine before.
Thank you for all of the help!
-