<?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[How can I flush QScrollBars with their containing QFrames&#x2F;QWidgets via. QSS?]]></title><description><![CDATA[<p dir="auto">I have a stylesheet with custom styled QScrollBars. The QSS is as follows (I am aware it's messy):</p>
<pre><code>QScrollBar, QScrollBar::add-line, QScrollBar::sub-line
{
    background-color: @button-background;
    border: 1px solid @button-border;
}
QScrollBar:horizontal
{
    padding-left: 13px;
    padding-right: 13px;
}
QScrollBar:vertical
{
    padding-top: 13px;
    padding-bottom: 13px;
}
QScrollBar::add-line:hover, QScrollBar::sub-line:hover
{
    background-color: @button-highlight;
}
QScrollBar::add-line:pressed, QScrollBar::sub-line:pressed
{
    background-color: @button-down;
}
QScrollBar
{
    border-radius: 6px;
}
QScrollBar::left-arrow
{
    image: url(images/left_arrow.png);
}
QScrollBar::right-arrow
{
    image: url(images/right_arrow.png);
}
QScrollBar::up-arrow
{
    image: url(images/up_arrow.png);
}
QScrollBar::down-arrow
{
    image: url(images/down_arrow.png);
}

QScrollBar::add-line:vertical
{
    border-top-left-radius: 0px;
    border-top-right-radius: 0px;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
    border-top: 0px;
}
QScrollBar::sub-line:vertical
{
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    border-bottom-left-radius: 0px;
    border-bottom-right-radius: 0px;
    border-bottom: 0px;
}
QScrollBar::add-line:horizontal
{
    border-top-left-radius: 0px;
    border-top-right-radius: 6px;
    border-bottom-left-radius: 0px;
    border-bottom-right-radius: 6px;
    border-left: 0px;
}
QScrollBar::sub-line:horizontal
{
    border-top-left-radius: 6px;
    border-top-right-radius: 0px;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 0px;
    border-right: 0px;
}

QScrollBar::handle
{
    border: 0px solid;
    border-radius: 3px;
    width: 8px;
    margin: 2px;
    background-color: @button-down;
}
QScrollBar::handle:vertical
{
    min-height: 10px;
}
QScrollBar::handle:horizontal
{
    min-width: 10px;
}
QScrollBar::handle:hover
{
    background-color: @button-border;
}
</code></pre>
<p dir="auto">QScrollArea:</p>
<pre><code>QGroupBox, QScrollArea
{
    border: 1px solid @button-border;
    border-radius: 6px;
    background-color: rgba(0,0,0,8);
}
</code></pre>
<p dir="auto">While the color shouldn't have anything to do with it, the <code>@button-border</code>, <code>@button-highlight</code>, etc. are custom implemented variables.</p>
<p dir="auto">When I create a QScrollArea, the scroll bars look like this:<br />
<img src="https://ddgobkiprc33d.cloudfront.net/863c25b8-64ed-4caf-90e3-0cb1c6b2ce21.png" alt="50bc6762-d58e-4321-a59e-014699d11759-image.png" class=" img-fluid img-markdown" /><br />
I would like for the scroll bars' bottom &amp; right borders to match with the scroll area's borders (i.e. flush).</p>
<p dir="auto">I have tried setting the padding of the QScrollArea to a negative value (-1px). This partially worked, but then the borders of the scroll area itself were no longer present.<br />
Example:<br />
<img src="https://ddgobkiprc33d.cloudfront.net/a8bb3ca4-a339-4f0e-8483-cb09e3e40302.png" alt="0fbc8188-6538-481d-858c-e2fe7e2b20a1-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">I have tried setting the margin of the QScrollBars whose parents are QScrollAreas to a negative value (-1px). This screwed up the scroll bar in many ways.<br />
Example:<br />
<img src="https://ddgobkiprc33d.cloudfront.net/24520b2f-c8f5-473b-be81-acb7ffda2946.png" alt="55294cdb-8722-41ff-bccf-bf5c259d0d26-image.png" class=" img-fluid img-markdown" /></p>
<ul>
<li>It does not set the subcontrols padding properly.</li>
<li>It removes the border on the QScrollBar.</li>
<li>It does not extend the width/height of the bars properly, so the 1px issue is still in place on the top &amp; left.<br />
I believe the first 2 issues are that it isn't applying recursively to the QScrollBar, so I would have to set the property for all the subcontrols and fix the border issue. I feel like there is a better way.</li>
</ul>
<p dir="auto">Every other fix ends with undesirable effects. The Qt Style Sheets Reference and Qt Style Sheets Examples pages say nothing about the QScrollArea.<br />
This might be easily solved with CSS's inner padding &amp; margin, but from what I can tell there is no such thing in the QSS engine.</p>
<p dir="auto">Also, I would also like to set the border color of the black square thing in the bottom right corner to transparent, and for the border-radius to work properly and not clip at the top-left corner.<br />
Mockup of desired effect:<br />
<img src="https://ddgobkiprc33d.cloudfront.net/b6cf54db-daa8-4ceb-9bcb-5603c5f6583f.png" alt="a5aa20b1-a625-4006-80e9-205ed42f6960-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/topic/128263/how-can-i-flush-qscrollbars-with-their-containing-qframes-qwidgets-via-qss</link><generator>RSS for Node</generator><lastBuildDate>Thu, 06 Aug 2026 12:56:35 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/128263.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 07 Jul 2021 01:28:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How can I flush QScrollBars with their containing QFrames&#x2F;QWidgets via. QSS? on Wed, 07 Jul 2021 05:24:48 GMT]]></title><description><![CDATA[<p dir="auto">Though I appreciate your suggestion -- they are both already at 0, as you can see here:<br />
<img src="https://ddgobkiprc33d.cloudfront.net/e9f5538b-e4b3-40c5-816e-c4f5a030f3be.png" alt="0c5e90c0-8a91-4804-a21e-c6abda2f522c-image.png" class=" img-fluid img-markdown" /><br />
This is me redeclaring margin &amp; padding for the scroll elements so I don't have to pick through the sea of QSS I've written to find where they're initially set :)</p>
<p dir="auto">What I want is not for the horizontal or vertical scroll bars to occupy the black square, just for the black square to not be visible. I think you picked up on that by the end of my first post, though. I can definitely see why you think that :p</p>
<hr />
<p dir="auto">Edit: THIS IS STUPID: DONT DO THIS<br />
<s>As for negative values, I already toyed around with those -- the third screenshot in my initial post was just setting <code>padding: -1px;</code> on the QScrollBars that are children of a QScrollArea. Fleshing out a bit more the way I'd imagine would fix it just does this:<br />
<img src="https://ddgobkiprc33d.cloudfront.net/41bd8d17-8a07-4297-9b19-db9db6d50e6e.png" alt="30668a7b-4271-4da4-b3ac-d5da42bece01-image.png" class=" img-fluid img-markdown" /><br />
Yeah, it fixes the border issue, but creates a plethora of other ones. The <code>sub-line</code> and <code>add-line</code> subcontrols seem to take over the whole horizontal/vertical space, and I cannot access the <code>handle</code> (that also happens to be oversized).</s><br />
DO THIS INSTEAD:</p>
<pre><code>QScrollArea QScrollBar::horizontal
{
    margin: -1px;
    margin-top: 1px;
}
QScrollArea QScrollBar::vertical
{
    margin: -1px;
    margin-left: 1px;
}
</code></pre>
<p dir="auto">As long as your subcontrol positions &amp; sizes are set properly, there should not be any setting of margins needed beyond this.</p>
<hr />
<p dir="auto">The two border lines are what's already happening without any extra QSS, that's what my first screenshot was. Thank you for your suggestions!</p>
<p dir="auto">Edit: I forgot about the fact that I had already set margins for the scroll bars. Making the margins negative does not break anything. It does work, but I would like to know if there is a better way than manually setting margins of specific widgets' children before I close this topic as solved. Also I can't get rid of this box...</p>
]]></description><link>https://forum.qt.io/post/669276</link><guid isPermaLink="true">https://forum.qt.io/post/669276</guid><dc:creator><![CDATA[Ewan Green]]></dc:creator><pubDate>Wed, 07 Jul 2021 05:24:48 GMT</pubDate></item><item><title><![CDATA[Reply to How can I flush QScrollBars with their containing QFrames&#x2F;QWidgets via. QSS? on Wed, 07 Jul 2021 04:08:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ewan-green">@<bdi>Ewan-Green</bdi></a> said in <a href="/post/669263">How can I flush QScrollBars with their containing QFrames/QWidgets via. QSS?</a>:</p>
<blockquote>
<p dir="auto">I would like for the scroll bars' bottom &amp; right borders to match with the scroll area's borders (i.e. flush).</p>
</blockquote>
<p dir="auto">At first read it looked to me like you are asking for:</p>
<ul>
<li>the horizontal scrollbar to extend rightwards into the small corner box outlined in black, <em>and</em></li>
<li>the vertical scrollbar to downwards into the small corner box outlined in black</li>
</ul>
<p dir="auto">Which bent my mind :)</p>
<p dir="auto">Back to the request...<br />
I think you want to reduce the QScrollBar right (or bottom) margin, not padding,  to zero pixels.<br />
You may also need to reduce the QScrollArea right (or bottom) padding  to zero pixels.<br />
That should put the two border lines immediately next to each other (it's possible that's already the case).   You might also tinker with negative one margins on the scroll bars.</p>
]]></description><link>https://forum.qt.io/post/669272</link><guid isPermaLink="true">https://forum.qt.io/post/669272</guid><dc:creator><![CDATA[ChrisW67]]></dc:creator><pubDate>Wed, 07 Jul 2021 04:08:29 GMT</pubDate></item></channel></rss>