<?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[Add QWidget above QToolBar in QMainWindow]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I have a QMainWindow with a central widget, left docked widget and a right docked widget.<br />
I also have  a toolbar at  the top.</p>
<p dir="auto">Below screenshot depicts my current layout structure.<br />
<img src="https://ddgobkiprc33d.cloudfront.net/dcd66281-5372-4e6c-b55a-46345c645c59.png" alt="438f5a48-4e2b-4884-97fe-9a253ea45410-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">I would like to add a widget on top of the toolbar that would contain the user info like name, DOB etc.<br />
Expected layout is as depicted by the below image<br />
<img src="https://ddgobkiprc33d.cloudfront.net/f5cb5dff-fb14-4eac-bdcf-fa6817256590.png" alt="13180d42-c84a-461f-9dd7-df973030b05e-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Is there a way to do it??<br />
I tried creating a vertical layout with title widget and toolbar, and added that layout above central widget.<br />
But it doesn't help.</p>
<p dir="auto">Note: Title widget here is not the "window title", i want to have a separate widget on top of toolbar.</p>
<p dir="auto">Can anyone give me a heads up on this ? or is this atleast doable?</p>
]]></description><link>https://forum.qt.io/topic/110909/add-qwidget-above-qtoolbar-in-qmainwindow</link><generator>RSS for Node</generator><lastBuildDate>Mon, 05 Oct 2026 11:30:34 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/110909.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 22 Jan 2020 13:50:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Add QWidget above QToolBar in QMainWindow on Wed, 22 Jan 2020 18:49:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rizwan94">@<bdi>Rizwan94</bdi></a> said:</p>
<blockquote>
<p dir="auto">I tried creating a vertical layout with title widget and toolbar, and added that layout above central widget.</p>
</blockquote>
<p dir="auto">That's close, but you need one extra step.<br />
Create a plain QWidget, set a vertical layout on it, add your widget and toolbar to it and then use <a href="https://doc.qt.io/qt-5/qmainwindow.html#setMenuWidget" target="_blank" rel="noopener noreferrer nofollow ugc">setMenuWidget()</a> on your main window.</p>
<p dir="auto">EDIT: Or you can even make it simpler - just use your title widget directly as the menu bar.</p>
]]></description><link>https://forum.qt.io/post/573649</link><guid isPermaLink="true">https://forum.qt.io/post/573649</guid><dc:creator><![CDATA[Chris Kawa]]></dc:creator><pubDate>Wed, 22 Jan 2020 18:49:36 GMT</pubDate></item><item><title><![CDATA[Reply to Add QWidget above QToolBar in QMainWindow on Wed, 07 Oct 2020 18:04:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rizwan94">@<bdi>Rizwan94</bdi></a>  May I ask what was your final implementation? I'm trying to setup a frameless window and add my title/close buttons on top of an existing QMainWindow (from .ui)<br />
Thanks in advance</p>
]]></description><link>https://forum.qt.io/post/621184</link><guid isPermaLink="true">https://forum.qt.io/post/621184</guid><dc:creator><![CDATA[JulienMaille]]></dc:creator><pubDate>Wed, 07 Oct 2020 18:04:42 GMT</pubDate></item><item><title><![CDATA[Reply to Add QWidget above QToolBar in QMainWindow on Thu, 23 Jan 2020 07:41:38 GMT]]></title><description><![CDATA[<p dir="auto">Thanks <a class="plugin-mentions-user plugin-mentions-a" href="/user/chris-kawa">@<bdi>Chris-Kawa</bdi></a><br />
Works like a charm!!</p>
]]></description><link>https://forum.qt.io/post/573743</link><guid isPermaLink="true">https://forum.qt.io/post/573743</guid><dc:creator><![CDATA[Rizwan94]]></dc:creator><pubDate>Thu, 23 Jan 2020 07:41:38 GMT</pubDate></item><item><title><![CDATA[Reply to Add QWidget above QToolBar in QMainWindow on Wed, 22 Jan 2020 18:49:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rizwan94">@<bdi>Rizwan94</bdi></a> said:</p>
<blockquote>
<p dir="auto">I tried creating a vertical layout with title widget and toolbar, and added that layout above central widget.</p>
</blockquote>
<p dir="auto">That's close, but you need one extra step.<br />
Create a plain QWidget, set a vertical layout on it, add your widget and toolbar to it and then use <a href="https://doc.qt.io/qt-5/qmainwindow.html#setMenuWidget" target="_blank" rel="noopener noreferrer nofollow ugc">setMenuWidget()</a> on your main window.</p>
<p dir="auto">EDIT: Or you can even make it simpler - just use your title widget directly as the menu bar.</p>
]]></description><link>https://forum.qt.io/post/573649</link><guid isPermaLink="true">https://forum.qt.io/post/573649</guid><dc:creator><![CDATA[Chris Kawa]]></dc:creator><pubDate>Wed, 22 Jan 2020 18:49:36 GMT</pubDate></item><item><title><![CDATA[Reply to Add QWidget above QToolBar in QMainWindow on Wed, 22 Jan 2020 17:13:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rizwan94">@<bdi>Rizwan94</bdi></a><br />
Before someone else comes up with some clever way to achieve it....</p>
<p dir="auto">A <code>QMainWindow</code> has its layout as per <a href="https://doc.qt.io/qt-5/qmainwindow.html#details" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-5/qmainwindow.html#details</a> picture, and I don't see it offering you to change that framework.  So using a <code>QMainWindow</code> feels like a square peg &amp; a round hole.  Are you tied to <code>QMainWindow</code>.  If it's your own code and not tied, I'd have a <code>QWidget</code> with the furniture bits added to it.  Like I say, until someone says yours can be done with a one-liner on <code>QMainWindow</code>.</p>
<p dir="auto">Another <em>possibility</em> is to try inherited <code>QWidget::setLayout()</code> on a <code>QMainWindow</code>.  Find out how they've laid it out, and insert your extra title widget before the toolbar ( how did you do your "added that layout above central widget"?).  But don't blame me if it doesn't work or makes something go wrong!</p>
]]></description><link>https://forum.qt.io/post/573630</link><guid isPermaLink="true">https://forum.qt.io/post/573630</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Wed, 22 Jan 2020 17:13:24 GMT</pubDate></item></channel></rss>