You can't style an "<a>" element in a QLabel via the Qt theme stylesheets, only via css embedded/hardcoded directly in the QLabel. But of course we really need to be able to style via a stylesheet! For standalone URLs we've historically solved this by specifically creating a "UrlLabel" subclass. You then put an "<a>" element, and ONLY that element, in that label. It gets styled independently, and viola! A "styled" URL. The problem is that Sketcher's URL is not standalone: in some cases, like the one shown above, the link is embedded within the sentence (in this case "2 degrees" is a link).
I have three proposed solutions to this (and am open to whatever others you can come up with!):
- Separate the single label into three: "preURlLabel", "urlLabel", "postUrlLabel" and put them in a horizontal layout. As long as no wrapping occurs, this will look the same as it does now. It's a bit awkward in the code, but not totally horrifying.
- Separate the single label into two, and change the link to always be at the end. So, e.g. "Under-constrained sketch with 2 degrees of freedom. (Click to select)". Possibly place this label underneath the other, so wrapping is not an issue. Code is nicer-looking than option 1, but changes what the UI looks like.
- Switch from a link/url to a QPushButton, either to the right or below the text. Label that button "Select DOFS", "Select redundants", etc. as needed. Cleaner code (no extra style handling needed, buttons look like buttons), but much bigger UI change.
Note: Details of the solution for the QLabel coloring... I think I've managed to solve this problem by creating a new QLabel subclass called "StatefulLabel" that can have arbitrary style information set for arbitrary "states" (which are just strings, so things like "overconstrained" or "partially redundant constraints", etc.). Stylesheets can set up a style for a given state, and if it's not set it falls back to the default (e.g. red for overconstrained, green for fully constrained, etc.). There's a bit more to it, but that's the gist. So, that's one solved problem.