{"id":75,"date":"2008-01-17T12:28:24","date_gmt":"2008-01-17T19:28:24","guid":{"rendered":"http:\/\/thesmithfam.org\/blog\/2008\/01\/17\/qt-stylesheets\/"},"modified":"2019-08-12T07:16:11","modified_gmt":"2019-08-12T13:16:11","slug":"qt-stylesheets","status":"publish","type":"post","link":"https:\/\/thesmithfam.org\/blog\/2008\/01\/17\/qt-stylesheets\/","title":{"rendered":"Qt Stylesheets"},"content":{"rendered":"<p>I&#8217;m a new convert to Qt&#8217;s stylesheets. They make customizing your Qt GUI much easier than other methods (like QPalette). Recently, I responded to a request for comments from Trolltech, and I thought my fellow GUI developers might be interested in it.<\/p>\n<p>These are my humble suggestions to Trolltech for improving Qt stylesheets:<\/p>\n<blockquote><p>\nI use stylesheets extensively for both tweaking and completely changing the look of a widget. By far, the most common thing I do with stylesheets is set the border of QFrames. They make it so easy to do this, for example:<\/p>\n<p>border: none;<br \/>\nborder-bottom: 1px solid black;<\/p>\n<p>I also use them a lot for QFrame background colors. I find it much easier than messing with QPalette, especially when it comes to alpha transparency, background images, and gradient backgrounds.<\/p>\n<p>My number 1 request: Let us reference an external CSS file in our stylesheet. In my current project, I had to patch designer so I could apply the same stylesheet to all my UI files, and actually see that style in Designer while working with it. If I could refer to an external file, I would make each Designer form point to a single stylesheet file (foo.css or :\/foo.css), such that I could use a global stylesheet for all forms in my project and actually see how it will look in Designer before building and running my program.<\/p>\n<p>My number 2 request (much less important): Make it easier to change single elements of a stylesheet programmatically. I often have the case where, for example, I want to change a blue gradient background to a gray one (say, when my widget is disabled). My stylesheet also has dozens of other settings that I don\u00e2\u20ac\u2122t want to change (like border color, fonts, etc). It would be nice if I could access elements of the stylesheets like a DOM tree, and modify them in place without having to do search and replace on a QString. Currently the way I do it is with CSS comments. I place a START and END comment and then do search and replace to modify styles programmatically. It\u00e2\u20ac\u2122s a hack, and I would like more fine-grained control than that.<\/p>\n<p>In short, stylesheets are absolutely fantastic. I love that you have taken a wildly successful web concept and merged it into the world\u00e2\u20ac\u2122s best GUI toolkit. Thank you Trolls!\n<\/p><\/blockquote>\n<p>These words of mine come from:<br \/>\n<a href=\"http:\/\/labs.trolltech.com\/blogs\/2008\/01\/11\/tale-of-an-artist\/#comment-16393\">http:\/\/labs.trolltech.com\/blogs\/2008\/01\/11\/tale-of-an-artist\/#comment-16393<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m a new convert to Qt&#8217;s stylesheets. They make customizing your Qt GUI much easier than other methods (like QPalette). Recently, I responded to a request for comments from Trolltech, and I thought my fellow GUI developers might be interested in it. These are my humble suggestions to Trolltech for improving Qt stylesheets: I use [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-75","post","type-post","status-publish","format-standard","hentry","category-code-and-cruft"],"_links":{"self":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts\/75","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/comments?post=75"}],"version-history":[{"count":1,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts\/75\/revisions"}],"predecessor-version":[{"id":1571,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts\/75\/revisions\/1571"}],"wp:attachment":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/media?parent=75"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/categories?post=75"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/tags?post=75"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}