{"id":182,"date":"2015-03-14T18:03:45","date_gmt":"2015-03-14T23:03:45","guid":{"rendered":"http:\/\/eastfist.com\/qt_tutorials\/?p=182"},"modified":"2017-08-26T03:30:03","modified_gmt":"2017-08-26T09:30:03","slug":"how-to-create-x11-colors-into-qt-qcolor-wrapper","status":"publish","type":"post","link":"https:\/\/eastfist.com\/qt_tutorials\/how-to-create-x11-colors-into-qt-qcolor-wrapper\/","title":{"rendered":"How to create X11 colors into Qt QColor Wrapper"},"content":{"rendered":"<p>You can mix any color you want nowadays with 32-bit colors. But sometimes, it&#8217;s just so much more convenient if the color palette already exists. And unfortunately, Qt only provides users with the most basic of colors. Therefore, it&#8217;s up to you to come up with a snazzy pre-mixed color palette yourself, but also to name those custom colors. But you don&#8217;t need to reinvent the wheel. <a href=\"http:\/\/en.wikipedia.org\/wiki\/Web_colors#X11_color_names\">The X Windows system and W3 web standard for colors and names already exists<\/a>.<\/p>\n<p>Unfortunately, if you&#8217;re using Qt on Windows, you won&#8217;t be able to access that color palette.<\/p>\n<p>So this is what I did: I simply took the names and RGB values and created a wrapper class in Qt. That way I can easily access the colors via their names. Ain&#8217;t that a trip? It seems so simple to implement, but I haven&#8217;t found any tutorials out there on the Interwebs. It could save a lot of time for those that deal with a lot of colors.<\/p>\n<p>Also, I whipped up a quick demo that displays the colors all nice and purdy.<\/p>\n<figure id=\"attachment_183\" aria-describedby=\"caption-attachment-183\" style=\"width: 300px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/eastfist.com\/qt_tutorials\/wp-content\/uploads\/2015\/03\/x11_QColors.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-183\" src=\"http:\/\/eastfist.com\/qt_tutorials\/wp-content\/uploads\/2015\/03\/x11_QColors-300x59.png\" alt=\"X11 colors as QColor in Qt 4.8.5\" width=\"300\" height=\"59\" \/><\/a><figcaption id=\"caption-attachment-183\" class=\"wp-caption-text\">X11 colors as QColor in Qt 4.8.5<\/figcaption><\/figure>\n<p>Feel free to use this X11 color name wrapper class in your Qt project. Enjoy!<\/p>\n<p>You can download the Qt 4.8.5 project files here:<br \/>\n<a href=\"http:\/\/eastfist.com\/qt_tutorials\/wp-content\/uploads\/2015\/03\/X11_colors_qt.zip\">X11_colors_qt<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can mix any color you want nowadays with 32-bit colors. But sometimes, it&#8217;s just so much more convenient if the color palette already exists. And unfortunately, Qt only provides users with the most basic of colors. Therefore, it&#8217;s up to you to come up with a snazzy pre-mixed color palette yourself, but also to &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/eastfist.com\/qt_tutorials\/how-to-create-x11-colors-into-qt-qcolor-wrapper\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to create X11 colors into Qt QColor Wrapper&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-182","post","type-post","status-publish","format-standard","hentry","category-qt-2"],"_links":{"self":[{"href":"https:\/\/eastfist.com\/qt_tutorials\/wp-json\/wp\/v2\/posts\/182","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eastfist.com\/qt_tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eastfist.com\/qt_tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eastfist.com\/qt_tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eastfist.com\/qt_tutorials\/wp-json\/wp\/v2\/comments?post=182"}],"version-history":[{"count":5,"href":"https:\/\/eastfist.com\/qt_tutorials\/wp-json\/wp\/v2\/posts\/182\/revisions"}],"predecessor-version":[{"id":329,"href":"https:\/\/eastfist.com\/qt_tutorials\/wp-json\/wp\/v2\/posts\/182\/revisions\/329"}],"wp:attachment":[{"href":"https:\/\/eastfist.com\/qt_tutorials\/wp-json\/wp\/v2\/media?parent=182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eastfist.com\/qt_tutorials\/wp-json\/wp\/v2\/categories?post=182"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eastfist.com\/qt_tutorials\/wp-json\/wp\/v2\/tags?post=182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}