Attempting to modify the style of a window and all its children using stylesheets.
Each child is given a name using setObjectName
, and the stylesheet uses these names to modify the style of the named widgets, along with a few exceptions. To achieve this, I create a map in C++, mapping names like QWidget#hello!hover
to key-value pairs such as background-color
to #0f0f0f
. For example,
["QWidget#hello!hover"]["background-color"] = "#0f0f0f"
represents one entry.
After changing the stylesheet map, I recalculate the entire stylesheet and apply it via
setStyleSheet</code on the main widget. I add <code>/* */
at the top to trigger a recalculation, but it doesn't seem to work as expected.
While this method works in the constructor of the main widget, it doesn't take effect after the initial setup.
The calculated stylesheet is valid, and all entries are in the expected order. Since it works initially, the issue may be that the new stylesheet is not being applied or has no effect on the children.
I am using Qt 5.4 on Windows 10. How can I resolve this issue?