<?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[Get first QDockWidget from a given area]]></title><description><![CDATA[<p dir="auto">How can I find the first QDockWidget for a given dock area (ie,.  Qt::BottomDockWidgetArea) ?</p>
<p dir="auto">Thanks.</p>
]]></description><link>https://forum.qt.io/topic/9671/get-first-qdockwidget-from-a-given-area</link><generator>RSS for Node</generator><lastBuildDate>Sun, 16 Aug 2026 00:30:53 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/9671.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 20 Sep 2011 16:38:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Get first QDockWidget from a given area on Wed, 21 Sep 2011 15:53:53 GMT]]></title><description><![CDATA[<p dir="auto">Thanks, I ended up doing something similar.  I'm surprised there are not direct api calls to help with this.</p>
]]></description><link>https://forum.qt.io/post/110360</link><guid isPermaLink="true">https://forum.qt.io/post/110360</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Wed, 21 Sep 2011 15:53:53 GMT</pubDate></item><item><title><![CDATA[Reply to Get first QDockWidget from a given area on Wed, 21 Sep 2011 10:49:07 GMT]]></title><description><![CDATA[<p dir="auto">There isn't really an API provided for achieving this. You could check the positioning of the dockwidgets though to figure out which one is first in the area. The example below illustrates this idea. Does following this approach help?</p>
<p dir="auto">@<br />
#include &lt;QtGui&gt;</p>
<p dir="auto">class MainWindow : public QMainWindow<br />
{<br />
Q_OBJECT<br />
public:<br />
MainWindow()<br />
{</p>
<p dir="auto">QTextEdit *edit1 = new QTextEdit(this);<br />
setCentralWidget(edit1);</p>
<p dir="auto">QDockWidget *topDock = new QDockWidget(this);<br />
topDock-&gt;setObjectName("Top dock");<br />
topDock-&gt;setWidget(new QLineEdit("Top dock", topDock));<br />
addDockWidget(Qt::TopDockWidgetArea, topDock);</p>
<p dir="auto">dock1 = new QDockWidget(this);<br />
dock1-&gt;setObjectName("Dock 1");<br />
dock1-&gt;setWidget(new QLineEdit("First dock", dock1));<br />
dock2 = new QDockWidget(this);<br />
dock2-&gt;setObjectName("Dock 2");<br />
dock2-&gt;setWidget(new QPushButton("Second dock", dock2));</p>
<p dir="auto">addDockWidget(Qt::BottomDockWidgetArea, dock1);<br />
addDockWidget(Qt::BottomDockWidgetArea, dock2, Qt::Vertical);<br />
QTimer <em>timer = new QTimer(this);<br />
timer-&gt;start(3000);<br />
connect(timer, SIGNAL(timeout()), this, SLOT(testSlot()));<br />
dockList = findChildren&lt;QDockWidget</em>&gt;();</p>
<p dir="auto">}<br />
public slots:<br />
void testSlot()<br />
{<br />
for (int i = 0; i &lt; dockList.count(); i++) {<br />
QDockWidget *dock = <a href="http://dockList.at" target="_blank" rel="noopener noreferrer nofollow ugc">dockList.at</a>(i);</p>
<pre><code>int dockTopLeft = dock-&gt;geometry().topLeft().y();
int  centralWidBottom = centralWidget()-&gt;geometry().bottomLeft().y();
int offset = dockTopLeft  - centralWidBottom;

if (dockWidgetArea(dock) == Qt::BottomDockWidgetArea &amp;&amp; dock-&gt;geometry().bottomLeft().x() == 0 &amp;&amp; offset &lt; 10) {
 qDebug() &lt;&lt; dock-&gt;objectName() &lt;&lt; " is first in the bottom dock area";
}
</code></pre>
<p dir="auto">}}</p>
<p dir="auto">private:<br />
QDockWidget *dock1;<br />
QDockWidget <em>dock2;<br />
QList&lt;QDockWidget</em>&gt; dockList;</p>
<p dir="auto">};</p>
<p dir="auto">#include "main.moc"<br />
int main(int argc, char** argv)<br />
{<br />
QApplication app(argc, argv);<br />
MainWindow window;<br />
window.show();<br />
return app.exec();</p>
<p dir="auto">}<br />
@</p>
]]></description><link>https://forum.qt.io/post/110306</link><guid isPermaLink="true">https://forum.qt.io/post/110306</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Wed, 21 Sep 2011 10:49:07 GMT</pubDate></item></channel></rss>