<?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[QWidget in QMainToolBar can not hide ?]]></title><description><![CDATA[<p dir="auto">I want to use a QPushButton to hide Breadcrumb Navigation and show QLineEdit of path in FileManager.<br />
I found QWidget in QMainToolBar can not hide.</p>
<pre><code>ui-&gt;mainToolBar-&gt;insertWidget(ui-&gt;action_edit_location, scrollArea);
lineEdit_location = new QLineEdit(path, this);
ui-&gt;mainToolBar-&gt;insertWidget(ui-&gt;action_edit_location, lineEdit_location);
connect(lineEdit_location, SIGNAL(returnPressed()), this, SLOT(lineEditLocationReturnPressed()));
lineEdit_location-&gt;hide();
connect(ui-&gt;action_edit_location, &amp;QAction::triggered, [=]{
    scrollArea-&gt;hide();
    lineEdit_location-&gt;show();
});
</code></pre>
<p dir="auto"><img src="https://s41.ax1x.com/2026/06/17/pm1XlTI.jpg" alt="alt" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/topic/164804/qwidget-in-qmaintoolbar-can-not-hide</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Jul 2026 17:06:54 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/164804.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 17 Jun 2026 07:29:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QWidget in QMainToolBar can not hide ? on Thu, 18 Jun 2026 08:37:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sonichy">@<bdi>sonichy</bdi></a></p>
<pre><code> Note: You should use QAction::setVisible() to change the visibility of the widget.
 Using QWidget::setVisible(), QWidget::show() and QWidget::hide() does not work.
</code></pre>
<p dir="auto">(from: <a href="https://doc.qt.io/qt-6/qtoolbar.html#insertWidget" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-6/qtoolbar.html#insertWidget</a>)</p>
<p dir="auto">So try:</p>
<pre><code>auto* scrollAreaAction = ui-&gt;mainToolBar-&gt;insertWidget(ui-&gt;action_edit_location, scrollArea);
lineEdit_location = new QLineEdit(path, this);
auto* lineEditLocationAction = ui-&gt;mainToolBar-&gt;insertWidget(ui-&gt;action_edit_location, lineEdit_location);
lineEditLocationAction-&gt;setVisible(false);
connect(ui-&gt;action_edit_location, &amp;QAction::triggered, [=]{
    scrollAreaAction-&gt;setVisible(false);
    lineEditLocationAction-&gt;setVisible(true);
});
</code></pre>
]]></description><link>https://forum.qt.io/post/838796</link><guid isPermaLink="true">https://forum.qt.io/post/838796</guid><dc:creator><![CDATA[Pl45m4]]></dc:creator><pubDate>Thu, 18 Jun 2026 08:37:47 GMT</pubDate></item><item><title><![CDATA[Reply to QWidget in QMainToolBar can not hide ? on Thu, 18 Jun 2026 04:51:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sonichy">@<bdi>sonichy</bdi></a> said in <a href="/post/838804">QWidget in QMainToolBar can not hide ?</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/pl45m4">@<bdi>Pl45m4</bdi></a> QWidget::setVisible() is useless too.</p>
</blockquote>
<p dir="auto">This is what he wrote...</p>
<p dir="auto">"Note: You should use QAction::setVisible() to change the visibility of the widget.<br />
Using QWidget::setVisible(), QWidget::show() and QWidget::hide() does not work."</p>
]]></description><link>https://forum.qt.io/post/838805</link><guid isPermaLink="true">https://forum.qt.io/post/838805</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Thu, 18 Jun 2026 04:51:45 GMT</pubDate></item><item><title><![CDATA[Reply to QWidget in QMainToolBar can not hide ? on Thu, 18 Jun 2026 05:04:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/pl45m4">@<bdi>Pl45m4</bdi></a> Understand, can not hide QWidget directly, can setVisible of QAction.<br />
QAction *action = ui-&gt;mainToolBar-&gt;insertWidget(QAction, QWidget);<br />
action-&gt;setVisible(false);</p>
]]></description><link>https://forum.qt.io/post/838804</link><guid isPermaLink="true">https://forum.qt.io/post/838804</guid><dc:creator><![CDATA[sonichy]]></dc:creator><pubDate>Thu, 18 Jun 2026 05:04:20 GMT</pubDate></item><item><title><![CDATA[Reply to QWidget in QMainToolBar can not hide ? on Thu, 18 Jun 2026 08:37:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sonichy">@<bdi>sonichy</bdi></a></p>
<pre><code> Note: You should use QAction::setVisible() to change the visibility of the widget.
 Using QWidget::setVisible(), QWidget::show() and QWidget::hide() does not work.
</code></pre>
<p dir="auto">(from: <a href="https://doc.qt.io/qt-6/qtoolbar.html#insertWidget" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-6/qtoolbar.html#insertWidget</a>)</p>
<p dir="auto">So try:</p>
<pre><code>auto* scrollAreaAction = ui-&gt;mainToolBar-&gt;insertWidget(ui-&gt;action_edit_location, scrollArea);
lineEdit_location = new QLineEdit(path, this);
auto* lineEditLocationAction = ui-&gt;mainToolBar-&gt;insertWidget(ui-&gt;action_edit_location, lineEdit_location);
lineEditLocationAction-&gt;setVisible(false);
connect(ui-&gt;action_edit_location, &amp;QAction::triggered, [=]{
    scrollAreaAction-&gt;setVisible(false);
    lineEditLocationAction-&gt;setVisible(true);
});
</code></pre>
]]></description><link>https://forum.qt.io/post/838796</link><guid isPermaLink="true">https://forum.qt.io/post/838796</guid><dc:creator><![CDATA[Pl45m4]]></dc:creator><pubDate>Thu, 18 Jun 2026 08:37:47 GMT</pubDate></item><item><title><![CDATA[Reply to QWidget in QMainToolBar can not hide ? on Wed, 17 Jun 2026 07:42:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joe-von-habsburg">@<bdi>Joe-von-Habsburg</bdi></a><br />
Although OP's exact problem/explanation is not very clear, I am assuming the slot/connection is not actually relevant?  OP starts with <code>lineEdit_location-&gt;hide();</code> outside of action/slot but shows both widgets, including <code>lineEdit</code> as already shown, which is wrong and <em>presumably</em> illustrates "I found QWidget in QMainToolBar can not hide".  It would be nice to have OP's confirmation of this, or whether they are only talking about what is supposed to happen in the signal/slot?</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sonichy">@<bdi>sonichy</bdi></a><br />
Normally the better way to show one widget at a time, while hiding other(s), is to put them both on a <code>QStackedWidget</code> rather than showing/hiding each one.  However I am not sure that would help your problem here.</p>
]]></description><link>https://forum.qt.io/post/838793</link><guid isPermaLink="true">https://forum.qt.io/post/838793</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Wed, 17 Jun 2026 07:42:21 GMT</pubDate></item><item><title><![CDATA[Reply to QWidget in QMainToolBar can not hide ? on Wed, 17 Jun 2026 07:37:22 GMT]]></title><description><![CDATA[<p dir="auto">does your slot function work ?  &amp;QAction::triggered might send signal</p>
]]></description><link>https://forum.qt.io/post/838792</link><guid isPermaLink="true">https://forum.qt.io/post/838792</guid><dc:creator><![CDATA[Joe von Habsburg]]></dc:creator><pubDate>Wed, 17 Jun 2026 07:37:22 GMT</pubDate></item></channel></rss>