<?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[QMenuBar does not show up]]></title><description><![CDATA[<p dir="auto">I ty to make a menuBar to change the language of my Application at run time. However the bar does not show up.</p>
<p dir="auto">Here is a snippet how i create the bar:</p>
<pre><code>class MainWindow : public QMainWindow
{
    Q_OBJECT
//...
private:
//...
    QMenu *mLanguageMenu;

};
</code></pre>
<pre><code>void MainWindow::createMenus()
{
    qDebug() &lt;&lt; menuBar()-&gt;actions().size();  // here its zero
    
    createLanguageMenu();

    menuBar()-&gt;addMenu(mLanguageMenu);

    qDebug() &lt;&lt; menuBar()-&gt;actions().size();  // here size is 1 so it was added
}
</code></pre>
<pre><code>void MainWindow::createLanguageMenu()
{
    mLanguageMenu = new QMenu{ this };

    mLanguageActionGroup = new QActionGroup{ this };

    connect(mLanguageActionGroup, &amp;QActionGroup::triggered,
            this, &amp;MainWindow::switchLanguage);

    QDir qmDir{":/translations"};
    auto fileNames = qmDir.entryList(QStringList("quiz_*.qm"));

    for (auto i=0; i &lt; fileNames.size(); ++i) {
        auto locale = fileNames[i];
        locale.remove(0, locale.indexOf('_') + 1);
        locale.chop(3);

        QTranslator translator;
        translator.load(fileNames[i], qmDir.absolutePath());
        auto language = translator.translate("MainWindow", "English");

        auto action = new QAction{tr("&amp;%1 %2").arg(i + 1).arg(language), this};

        action-&gt;setCheckable(true);
        action-&gt;setData(locale);

        mLanguageMenu-&gt;addAction(action);
        mLanguageActionGroup-&gt;addAction(action);

        if (language == "English") {
            action-&gt;setChecked(true);
        }
    }
}
</code></pre>
<p dir="auto">At first i thougth this was maybe a bug in KDE Neon but then i also compiled the code with Windows 10 but its the same  result. Any Idea what i do wrong? As you can see in the <code>qDebug()</code> statements it looks like the action gets added but does not show.</p>
]]></description><link>https://forum.qt.io/topic/106938/qmenubar-does-not-show-up</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Apr 2026 06:34:42 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/106938.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 16 Sep 2019 18:35:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QMenuBar does not show up on Tue, 17 Sep 2019 17:03:43 GMT]]></title><description><![CDATA[<p dir="auto">i foudn the issue. I added annother string with the string constructor as you recommended.<br />
The menu showed up. Then I realized that I don't give my menu a name. So i added</p>
<pre><code>mLanguageMenu-&gt;setTitle(tr("Language"));
</code></pre>
<p dir="auto">in the <code>void MainWindow::createLanguageMenu()</code> method and now it works fine.</p>
]]></description><link>https://forum.qt.io/post/551557</link><guid isPermaLink="true">https://forum.qt.io/post/551557</guid><dc:creator><![CDATA[sandro4912]]></dc:creator><pubDate>Tue, 17 Sep 2019 17:03:43 GMT</pubDate></item><item><title><![CDATA[Reply to QMenuBar does not show up on Mon, 16 Sep 2019 19:30:57 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Might be a silly question but did you check the number of actions added to your menu ?</p>
<p dir="auto">What version of Qt are you using ?<br />
What if you create your menu using the QMenuBar::addMenu overload that takes a string ?</p>
]]></description><link>https://forum.qt.io/post/551403</link><guid isPermaLink="true">https://forum.qt.io/post/551403</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Mon, 16 Sep 2019 19:30:57 GMT</pubDate></item></channel></rss>