Correct syntax for local image file?
-
wrote on 28 Jun 2020, 17:49 last edited by SPlatten
What is the correct syntax for an image file to be used with setStyleSheet ?
I've tried this:
background-image:url('file://Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png');
When I pass this to setStyleSheet, I see:
Could not create pixmap from file://Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png
In the Application output, I've also tried:
background-image:url('file:///Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png');
and
In the Application output, I've also tried:
background-image:url('://Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png');
and
background-image:url(':/Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png');
Same result. By the way, I'm working on an iMAC.
-
What is the correct syntax for an image file to be used with setStyleSheet ?
I've tried this:
background-image:url('file://Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png');
When I pass this to setStyleSheet, I see:
Could not create pixmap from file://Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png
In the Application output, I've also tried:
background-image:url('file:///Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png');
and
In the Application output, I've also tried:
background-image:url('://Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png');
and
background-image:url(':/Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png');
Same result. By the way, I'm working on an iMAC.
@SPlatten
this:background-image:url("/Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png");
should work:
Simple file path with full quotation marks -
wrote on 28 Jun 2020, 23:16 last edited by
I've not done it before, but isn't the resrouce locator format of :/path relative to the project top dir? Is the image compiled into the app, or expected to be accessed as a standalone support file, delivered with the app?
-
wrote on 29 Jun 2020, 05:55 last edited by
@Kent-Dorfman , these images are not built into the project the resources are designed to be on the local file system.
-
wrote on 29 Jun 2020, 06:25 last edited by
I'm currently not with a MAC so I can't test.
But did you try just "/Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png"? -
What is the correct syntax for an image file to be used with setStyleSheet ?
I've tried this:
background-image:url('file://Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png');
When I pass this to setStyleSheet, I see:
Could not create pixmap from file://Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png
In the Application output, I've also tried:
background-image:url('file:///Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png');
and
In the Application output, I've also tried:
background-image:url('://Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png');
and
background-image:url(':/Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png');
Same result. By the way, I'm working on an iMAC.
@SPlatten
this:background-image:url("/Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png");
should work:
Simple file path with full quotation marks -
What is the correct syntax for an image file to be used with setStyleSheet ?
I've tried this:
background-image:url('file://Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png');
When I pass this to setStyleSheet, I see:
Could not create pixmap from file://Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png
In the Application output, I've also tried:
background-image:url('file:///Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png');
and
In the Application output, I've also tried:
background-image:url('://Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png');
and
background-image:url(':/Users/simonplatten/XMLMPAM/config/images/meshtile_4x4.png');
Same result. By the way, I'm working on an iMAC.
@SPlatten As shown here: https://doc.qt.io/Qt-5/stylesheet-syntax.html there is no need for ''.
Also keep in mind that using absolute paths prevents your app from working properly on other machines... -
wrote on 29 Jun 2020, 09:22 last edited by SPlatten
@jsulm, although there is a default path that the application will use, it can also be overridden with a command line argument, once the application knows where to locate the configuration file (XML), everything else is specified in the XML.
The CSS contains just the file name, not the path, the application processes the CSS and if it finds a URI reference then it corrects the file spec. using the configured path.
1/7