<?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[Set Dashed Line&#x27;s Dash And Space Lengths In Pixels Instead Of In Line Width Units]]></title><description><![CDATA[<p dir="auto">As far as I can tell there is no way in Qt to set a dashed line's dash and space lengths in any unit other than multiples of line widths. That is a show stopper for me as I need to set them in pixels in order to draw a dashed line with dashes shorter than the line is wide. Is there any way to do that?</p>
<p dir="auto">I did try to set the dash and space lengths as fractions of the line width, but it did not work.</p>
<p dir="auto">Thanks.</p>
]]></description><link>https://forum.qt.io/topic/114485/set-dashed-line-s-dash-and-space-lengths-in-pixels-instead-of-in-line-width-units</link><generator>RSS for Node</generator><lastBuildDate>Sat, 26 Sep 2026 09:29:38 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/114485.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 05 May 2020 21:46:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Set Dashed Line&#x27;s Dash And Space Lengths In Pixels Instead Of In Line Width Units on Thu, 07 May 2020 20:39:01 GMT]]></title><description><![CDATA[<p dir="auto">Based on this <a href="https://gitlab.freedesktop.org/cairo/cairo/-/blob/master/src/cairo-qt.h" target="_blank" rel="noopener noreferrer nofollow ugc">file from the Cairo sources</a> I would say you should be good to go.</p>
]]></description><link>https://forum.qt.io/post/593427</link><guid isPermaLink="true">https://forum.qt.io/post/593427</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 07 May 2020 20:39:01 GMT</pubDate></item><item><title><![CDATA[Reply to Set Dashed Line&#x27;s Dash And Space Lengths In Pixels Instead Of In Line Width Units on Thu, 07 May 2020 20:01:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a></p>
<p dir="auto">No, I'm afraid not. From the documentation: <em>The dash pattern is specified in units of the pens width; e.g. a dash of length 5 in width 10 is 50 pixels long.</em></p>
<p dir="auto">And fractional line width units simply don't work. I tried that.</p>
<p dir="auto">Frankly I am surprised that the developers did this. I can see line width units for dashes and spaces as a convenience, but not at the expense of not being able to specify them in pixels.</p>
<p dir="auto">Unless I can find a way to use a Cairo context in Qt, I am afraid I am not going to be able to use Qt. So far, despite searching, I have found no information on that possibility.</p>
]]></description><link>https://forum.qt.io/post/593421</link><guid isPermaLink="true">https://forum.qt.io/post/593421</guid><dc:creator><![CDATA[Frogs-Mulligan]]></dc:creator><pubDate>Thu, 07 May 2020 20:01:58 GMT</pubDate></item><item><title><![CDATA[Reply to Set Dashed Line&#x27;s Dash And Space Lengths In Pixels Instead Of In Line Width Units on Thu, 07 May 2020 19:31:19 GMT]]></title><description><![CDATA[<p dir="auto">Doesn't QPen's <a href="https://doc.qt.io/qt-5/qpen.html#setWidth" target="_blank" rel="noopener noreferrer nofollow ugc">width</a> and <a href="https://doc.qt.io/qt-5/qpen.html#setDashPattern" target="_blank" rel="noopener noreferrer nofollow ugc">dash pattern</a> do what you want ?</p>
]]></description><link>https://forum.qt.io/post/593406</link><guid isPermaLink="true">https://forum.qt.io/post/593406</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 07 May 2020 19:31:19 GMT</pubDate></item><item><title><![CDATA[Reply to Set Dashed Line&#x27;s Dash And Space Lengths In Pixels Instead Of In Line Width Units on Thu, 07 May 2020 19:11:00 GMT]]></title><description><![CDATA[<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/0124a4d2-1777-4ad4-98b3-5f4179c39b12.png" alt="WideSpacedLine.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Sorry for the delay in getting back.</p>
<p dir="auto">The example is a single 130 pixel wide spaced line drawn using the Cairo graphics library, where  cr is a cairo context.  This works with any Cairo line, not just straight lines.</p>
<p dir="auto">I was hoping that Qt had a similar capabilty.</p>
<pre><code> double dashes[2] = {7.5, 30.0};
 cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.5);     
 cairo_set_line_width(cr, 130);                      
 cairo_set_antialias(cr,  CAIRO_ANTIALIAS_FAST);
 cairo_set_dash(cr, dashes, 2, 5);
 cairo_move_to(cr, 200, 200);
 cairo_line_to(cr, 1000, 200);
</code></pre>
]]></description><link>https://forum.qt.io/post/593384</link><guid isPermaLink="true">https://forum.qt.io/post/593384</guid><dc:creator><![CDATA[Frogs-Mulligan]]></dc:creator><pubDate>Thu, 07 May 2020 19:11:00 GMT</pubDate></item><item><title><![CDATA[Reply to Set Dashed Line&#x27;s Dash And Space Lengths In Pixels Instead Of In Line Width Units on Wed, 06 May 2020 18:50:07 GMT]]></title><description><![CDATA[<p dir="auto">Can you show an example of drawing you want to achieve ?</p>
]]></description><link>https://forum.qt.io/post/593092</link><guid isPermaLink="true">https://forum.qt.io/post/593092</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 06 May 2020 18:50:07 GMT</pubDate></item><item><title><![CDATA[Reply to Set Dashed Line&#x27;s Dash And Space Lengths In Pixels Instead Of In Line Width Units on Tue, 05 May 2020 22:01:06 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for the reminder.</p>
<p dir="auto">It' just QPainter and QPen in a QPaintEvent on a simple MainWindow. I did this as a test. I have very little Qt experience so I wanted to see if what I want to do is even possible.</p>
]]></description><link>https://forum.qt.io/post/592854</link><guid isPermaLink="true">https://forum.qt.io/post/592854</guid><dc:creator><![CDATA[Frogs-Mulligan]]></dc:creator><pubDate>Tue, 05 May 2020 22:01:06 GMT</pubDate></item><item><title><![CDATA[Reply to Set Dashed Line&#x27;s Dash And Space Lengths In Pixels Instead Of In Line Width Units on Tue, 05 May 2020 21:52:45 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">You should explain what you are using to draw these lines and on what you are drawing them.</p>
]]></description><link>https://forum.qt.io/post/592851</link><guid isPermaLink="true">https://forum.qt.io/post/592851</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 05 May 2020 21:52:45 GMT</pubDate></item></channel></rss>