<?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[Visible region in Qscrollarea]]></title><description><![CDATA[<p dir="auto">How to Get number of Visible widgets in scrollarea  as scrollarea gets created?</p>
]]></description><link>https://forum.qt.io/topic/93468/visible-region-in-qscrollarea</link><generator>RSS for Node</generator><lastBuildDate>Fri, 11 Sep 2026 07:06:15 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/93468.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 08 Aug 2018 05:14:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Visible region in Qscrollarea on Fri, 10 Aug 2018 05:57:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hjohn">@<bdi>hjohn</bdi></a> Sure it is. Just don't create any layout and put the labels manually somewhere in the widget_in_ScrollAra.<br />
Use widget_in_ScrollAra as parent for the labels.</p>
]]></description><link>https://forum.qt.io/post/475193</link><guid isPermaLink="true">https://forum.qt.io/post/475193</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Fri, 10 Aug 2018 05:57:25 GMT</pubDate></item><item><title><![CDATA[Reply to Visible region in Qscrollarea on Fri, 10 Aug 2018 05:53:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a> Thanks , It worked<br />
I have a further question...</p>
<pre><code>QScrollArea *ScrollArea=new QScrollArea;
QVBoxLayout *VLayout=new QVBoxLayout;
QWidget *widget_in_ScrollAra=new QWidget;

widget_in_ScrollAra-&gt;setLayout(VLayout);

for(int i=0;i&lt;20;i++){
     QLabel *Label=new QLabel;
     Label-&gt;setText(QString::number(i));
     VLayout-&gt;setWidget(Label);
}
ScrollArea-&gt;setWidget(widget_in_ScrollAra);

</code></pre>
<p dir="auto">That's how I'm setting my ScrollArea, But is there a way to add those <strong>Label</strong> into <strong>ScrollArea</strong> by making Labels children of <strong>widget_in_ScrollAra</strong> without using any Layout?</p>
]]></description><link>https://forum.qt.io/post/475192</link><guid isPermaLink="true">https://forum.qt.io/post/475192</guid><dc:creator><![CDATA[hjohn]]></dc:creator><pubDate>Fri, 10 Aug 2018 05:53:01 GMT</pubDate></item><item><title><![CDATA[Reply to Visible region in Qscrollarea on Fri, 10 Aug 2018 05:12:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a> Actually I want to Display how may widgets in Scrolllarea  are not visible at a time.</p>
]]></description><link>https://forum.qt.io/post/475187</link><guid isPermaLink="true">https://forum.qt.io/post/475187</guid><dc:creator><![CDATA[hjohn]]></dc:creator><pubDate>Fri, 10 Aug 2018 05:12:17 GMT</pubDate></item><item><title><![CDATA[Reply to Visible region in Qscrollarea on Thu, 09 Aug 2018 09:22:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hjohn">@<bdi>hjohn</bdi></a><br />
Hi<br />
well, you call it from constructor so widget is not yet visible and<br />
visibleRegion make no sense then.</p>
<p dir="auto">You could use /override<br />
<a href="http://doc.qt.io/qt-5/qwidget.html#showEvent" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5/qwidget.html#showEvent</a><br />
to first call it when shown.</p>
<p dir="auto">Alternatively, you must know size of scroll area and calculate how many is shown using<br />
buttons height. Since its not visible yet, it is not scrolled so should be pretty forward.</p>
<p dir="auto">Can i ask WHY you need to know how many is visible ?</p>
]]></description><link>https://forum.qt.io/post/474932</link><guid isPermaLink="true">https://forum.qt.io/post/474932</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Thu, 09 Aug 2018 09:22:59 GMT</pubDate></item><item><title><![CDATA[Reply to Visible region in Qscrollarea on Thu, 09 Aug 2018 07:12:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a></p>
<pre><code>Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui-&gt;setupUi(this);

      area=new QScrollArea(this);
      area-&gt;setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    for(int i=0;i&lt;23;i++){
        button=new QPushButton;
       button-&gt;setText(QString::number(i));
        layOut-&gt;addWidget(button);
    }
setlabels();
</code></pre>
<p dir="auto">setlabels() function:</p>
<pre><code> P=area-&gt;findChildren&lt;QPushButton*&gt;();
    for(int i=0;i&lt;P.count() ;i++)
{
        if(!P.at(i)-&gt;visibleRegion().isEmpty())
      {
                visibleButtonVectorBottom.push_back(P.at(i));
     }
 }
   
</code></pre>
]]></description><link>https://forum.qt.io/post/474874</link><guid isPermaLink="true">https://forum.qt.io/post/474874</guid><dc:creator><![CDATA[hjohn]]></dc:creator><pubDate>Thu, 09 Aug 2018 07:12:46 GMT</pubDate></item><item><title><![CDATA[Reply to Visible region in Qscrollarea on Thu, 09 Aug 2018 06:29:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hjohn">@<bdi>hjohn</bdi></a><br />
same to you :)<br />
If you provide a small sample that shows it<br />
count wrong, i will look into it.</p>
]]></description><link>https://forum.qt.io/post/474864</link><guid isPermaLink="true">https://forum.qt.io/post/474864</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Thu, 09 Aug 2018 06:29:02 GMT</pubDate></item><item><title><![CDATA[Reply to Visible region in Qscrollarea on Thu, 09 Aug 2018 06:27:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a> okay thanks...Have a  Good Day :)</p>
]]></description><link>https://forum.qt.io/post/474863</link><guid isPermaLink="true">https://forum.qt.io/post/474863</guid><dc:creator><![CDATA[hjohn]]></dc:creator><pubDate>Thu, 09 Aug 2018 06:27:54 GMT</pubDate></item><item><title><![CDATA[Reply to Visible region in Qscrollarea on Thu, 09 Aug 2018 06:22:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hjohn">@<bdi>hjohn</bdi></a><br />
ok. cant guess.  works 100% as expected for me.</p>
]]></description><link>https://forum.qt.io/post/474862</link><guid isPermaLink="true">https://forum.qt.io/post/474862</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Thu, 09 Aug 2018 06:22:01 GMT</pubDate></item><item><title><![CDATA[Reply to Visible region in Qscrollarea on Thu, 09 Aug 2018 06:18:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a>  yeah In My case It does  count but It counts 23 instead of 10. It gives right answer when i Scroll.</p>
]]></description><link>https://forum.qt.io/post/474861</link><guid isPermaLink="true">https://forum.qt.io/post/474861</guid><dc:creator><![CDATA[hjohn]]></dc:creator><pubDate>Thu, 09 Aug 2018 06:18:37 GMT</pubDate></item><item><title><![CDATA[Reply to Visible region in Qscrollarea on Thu, 09 Aug 2018 06:09:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hjohn">@<bdi>hjohn</bdi></a><br />
Im not sure how u use it.</p>
<p dir="auto">For me it counted the visible lables for me.<br />
With or without scrollbar. with/without scrolling.</p>
<p dir="auto"><strong>but they must be visible on screen before u count.</strong></p>
]]></description><link>https://forum.qt.io/post/474860</link><guid isPermaLink="true">https://forum.qt.io/post/474860</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Thu, 09 Aug 2018 06:09:08 GMT</pubDate></item><item><title><![CDATA[Reply to Visible region in Qscrollarea on Thu, 09 Aug 2018 05:10:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a> yeah I have used it <a href="http://before.It" target="_blank" rel="noopener noreferrer nofollow ugc">before.It</a> works only i scroll the scrollbar.<br />
But at beggining it counts total buttons.<br />
for example At the begging : only 10 buttons are visible from 23.<br />
above logic works only if i scroll the scrollbar but It does not work for start up scenario.I want to display 10 count when widgets added in scrollarea.<br />
<img src="https://ddgobkiprc33d.cloudfront.net/b297969b-0b5f-4781-a0e7-9c77787ee1a0.png" alt="0_1533791259708_Untitled.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/post/474847</link><guid isPermaLink="true">https://forum.qt.io/post/474847</guid><dc:creator><![CDATA[hjohn]]></dc:creator><pubDate>Thu, 09 Aug 2018 05:10:28 GMT</pubDate></item><item><title><![CDATA[Reply to Visible region in Qscrollarea on Wed, 08 Aug 2018 13:33:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hjohn">@<bdi>hjohn</bdi></a><br />
Hi<br />
you could do</p>
<pre><code> // count visible
  int count = 0;
  QList&lt;QLabel*&gt; labels = ui-&gt;scrollArea-&gt;findChildren&lt;QLabel*&gt;();
  for ( QLabel* label : labels) {
    if ( ! label-&gt;visibleRegion().isEmpty() ) { count++; }
  }

  qDebug() &lt;&lt; count;
</code></pre>
<p dir="auto">Note that if last label is only partly visible, its still counted.</p>
]]></description><link>https://forum.qt.io/post/474725</link><guid isPermaLink="true">https://forum.qt.io/post/474725</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Wed, 08 Aug 2018 13:33:15 GMT</pubDate></item><item><title><![CDATA[Reply to Visible region in Qscrollarea on Wed, 08 Aug 2018 07:23:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/raven-worx">@<bdi>raven-worx</bdi></a> Thanks for responding.</p>
<p dir="auto">There's scrollbar in my scenario and I've put a few labels in it.<br />
Now i have a slot which gets called when I scroll, and it works fine.<br />
That slot gives the visibleRegion of the QScrollArea.<br />
In constructor I have put 20 Qlabels in the scroll area so when the code gets executed the scrollbar allready has 20 Labels.<br />
on that time i want to know how many labels are visible in the scrollArea.</p>
]]></description><link>https://forum.qt.io/post/474623</link><guid isPermaLink="true">https://forum.qt.io/post/474623</guid><dc:creator><![CDATA[hjohn]]></dc:creator><pubDate>Wed, 08 Aug 2018 07:23:59 GMT</pubDate></item><item><title><![CDATA[Reply to Visible region in Qscrollarea on Wed, 08 Aug 2018 06:38:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hjohn">@<bdi>hjohn</bdi></a><br />
what exactly are you trying to achieve?</p>
]]></description><link>https://forum.qt.io/post/474604</link><guid isPermaLink="true">https://forum.qt.io/post/474604</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Wed, 08 Aug 2018 06:38:55 GMT</pubDate></item></channel></rss>