<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Trying to save the stylesheet options of an object after a new one has been created]]></title><description><![CDATA[<p dir="auto">Hi. I have an object (which is tied to a ui file) and a function that changes the stylesheet of said object such that the text would be in red. This object will be closed regularly and I would like to be able to save the modified stylesheet such that the text would remain red after I reopen the stylesheet. My stylesheet is defined in the ui file, and not the cpp file.</p>
<p dir="auto">The immediate method I can think of to "save" said stylesheet would be to create another object (maybe a QString that saves 'red', 'blue', 'black') and have it act as an input to the color changer function, then run the color changer everytime this object is created. However, I was wondering whether there is a simple way I could modify and save this new stylesheet such that I don't have to run this color changing function everytime I create the object.</p>
<p dir="auto">Please let me know if more information is required.</p>
]]></description><link>https://forum.qt.io/topic/139491/trying-to-save-the-stylesheet-options-of-an-object-after-a-new-one-has-been-created</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 06:18:42 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/139491.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 22 Sep 2022 08:32:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Trying to save the stylesheet options of an object after a new one has been created on Thu, 22 Sep 2022 19:43:26 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Shouldn't the change of color rather depend on the state of the widget ? You can use a dynamic property.</p>
<p dir="auto">Doing so you will need only one stylesheet without the need to change it yourself.</p>
]]></description><link>https://forum.qt.io/post/729847</link><guid isPermaLink="true">https://forum.qt.io/post/729847</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 22 Sep 2022 19:43:26 GMT</pubDate></item><item><title><![CDATA[Reply to Trying to save the stylesheet options of an object after a new one has been created on Thu, 22 Sep 2022 09:04:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dummie1138">@<bdi>Dummie1138</bdi></a><br />
You will indeed to save it yourself, the code generated (via <code>uic</code>) from your <code>.ui</code> file is for as it was when you designed it and hence will not contain the modification the next time you run the Qt program.</p>
<p dir="auto">Save the current <code>widget-&gt;styleSheet()</code> string, or whatever information you want to be able to redo what you need to do.  You might save it to <em>settings</em> via <code>QSettings</code>.  When your program starts, look for this saved value and if found apply to your widget during startup.</p>
]]></description><link>https://forum.qt.io/post/729747</link><guid isPermaLink="true">https://forum.qt.io/post/729747</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Thu, 22 Sep 2022 09:04:23 GMT</pubDate></item></channel></rss>