Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Background images don't show in Qt Creator unless you specify the full path. Anyone know a workaround ?
They show fine at runtime without a path.
So this in a styleSheet is fine for runtime:
But to see my foo at designtime, I must have:
Which isn't great for portability of source:
Bites me as working from OneDrive, which has a different path on my two work PCs:
I'm afraid, I can't use resources, to avoid this pathing problem - it's a Qt Script world only for us, due to the vendor utility sandbox we live in.
Infact, is it possible with Qt, to embed image data in the .xml ?
Say, in a text property that allows HTML, such as QLabel text ?
Something like the following, which you can do in full HTML:
<img src="data:image/png;base64,iVBORw0KG ... 5ErkJggg=="/>
Or alternatively, in a styleSheet property thus, which you can do in full CSS ?
background-image:url(data:image/png;base64,iVBORw0KG ... 5ErkJggg==)
Or, have my Qt Script .js code populate one or other of those properties ?
Hi J.Hilk, thanks for your reply there, much appreciated. I've just taken a look at the StandardPaths help. Looks interesting, but unfortunately, from our .js sandbox, we can use only signals, slots, accessible properties, and attributes. Though sandbox might have an issues with attribute, jury out on that. Thanks anyway. David
I've just tried base64 embedding. CSS didn't work, but HTML did, so I'm now path free :-)
And that indeed accords with the Qt CSS and HTML reference info, now I've taken a proper look.
Oh and images now show at designtime, and runtime on both my work PCs :-)
I randomly googled for base64 encode, and landed at https://www.base64encode.org/
onto which I dropped my pngs, it downloaded back at me a text equivalent.
It formats at 76 characters-per-line, I'm happy with that, no mile-long strings.
My icon .png remains an external file, but that's fine as Qt uses for that, just MyIcon.png,
So solved? Well found a different way. We could do with a 'Workedaround' button..