<?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[When size of viewport is defined?]]></title><description><![CDATA[<p dir="auto">Hello!</p>
<p dir="auto">I'm writing app with QScrollArea and going to set scroll bars values. Here's a piece of code:</p>
<p dir="auto">@<br />
MyScrollArea::MyScrollArea() {<br />
...<br />
// create scrollarea's widget<br />
CentralWidget = new QWidget(viewport());<br />
setWidget(CentralWidget);</p>
<pre><code>// set scrollarea's widget geometry
CentralWidget-&gt;setGeometry(0, 0, someWidth, someHeight);
CentralWidget-&gt;show();
CentralWidget-&gt;repaint();

// get viewport size
int viewWidth  = viewport()-&gt;width();
int viewHeight = viewport()-&gt;height();
//--------------------------------------------
</code></pre>
<p dir="auto">}@</p>
<p dir="auto">And got incorrect size of viewport: viewWidth = 28, viewHeight = 98. I consider that it's not defined yet, is it right?. When will I be able to get correct size?</p>
]]></description><link>https://forum.qt.io/topic/42191/when-size-of-viewport-is-defined</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 15:55:01 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/42191.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 04 Jun 2014 09:10:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to When size of viewport is defined? on Mon, 09 Jun 2014 17:39:33 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for reply! Maybe a bit later, but I'll try :)</p>
]]></description><link>https://forum.qt.io/post/231413</link><guid isPermaLink="true">https://forum.qt.io/post/231413</guid><dc:creator><![CDATA[alan73]]></dc:creator><pubDate>Mon, 09 Jun 2014 17:39:33 GMT</pubDate></item><item><title><![CDATA[Reply to When size of viewport is defined? on Mon, 09 Jun 2014 16:29:38 GMT]]></title><description><![CDATA[<p dir="auto">Here's an explanation of what may be happening to you:</p>
<p dir="auto"><a href="http://qt-project.org/forums/viewthread/5084" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/forums/viewthread/5084</a></p>
<p dir="auto">You can likely use Volker's solution to overcome this.</p>
<p dir="auto">Also, you can try calling show() first, then setGeometry() in your example, since you'll know someWidth and someHeight.</p>
]]></description><link>https://forum.qt.io/post/231407</link><guid isPermaLink="true">https://forum.qt.io/post/231407</guid><dc:creator><![CDATA[adolby]]></dc:creator><pubDate>Mon, 09 Jun 2014 16:29:38 GMT</pubDate></item></channel></rss>