<?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[QMessageBox  doesn&#x27;t translate the QString[Solved]]]></title><description><![CDATA[<p dir="auto">@ QInputDialog::getText(this,tr("Open"),tr("New"),QLineEdit::Normal,tr(""),&amp;ok);@</p>
<p dir="auto">the translator is loaded and installed but open and new<br />
don't get translated</p>
<p dir="auto">but if i do this :<br />
@//define Open and New in the mainwindow header file<br />
QString Open,New;<br />
//then define a new function<br />
rename()<br />
{<br />
Open=tr("Open");<br />
New=tr("New");<br />
}@</p>
<p dir="auto">then<br />
every time i switch the installer i call rename<br />
@rename();<br />
QInputDialog::getText(this,Open,New,QLineEdit::Normal,tr(""),&amp;ok);@</p>
<p dir="auto">translation works fine</p>
]]></description><link>https://forum.qt.io/topic/31734/qmessagebox-doesn-t-translate-the-qstring-solved</link><generator>RSS for Node</generator><lastBuildDate>Tue, 18 Aug 2026 17:15:47 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/31734.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 08 Sep 2013 22:24:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QMessageBox  doesn&#x27;t translate the QString[Solved] on Mon, 09 Sep 2013 04:26:11 GMT]]></title><description><![CDATA[<p dir="auto">Well done :) please add prefix [SOLVED] to the title of the thread.</p>
]]></description><link>https://forum.qt.io/post/194632</link><guid isPermaLink="true">https://forum.qt.io/post/194632</guid><dc:creator><![CDATA[leon.anavi]]></dc:creator><pubDate>Mon, 09 Sep 2013 04:26:11 GMT</pubDate></item><item><title><![CDATA[Reply to QMessageBox  doesn&#x27;t translate the QString[Solved] on Mon, 09 Sep 2013 04:01:10 GMT]]></title><description><![CDATA[<p dir="auto">i solved the problem the thing is before it was like this:</p>
<p dir="auto">@void retranslate()<br />
{<br />
QTranslator translator;//local variable gets destroyed when exiting<br />
translator.load(path);<br />
qApp-&gt;installTranslator(&amp;translator);<br />
}@</p>
<p dir="auto">and i solved it by moving the declaration of translator to the constructor<br />
@QTranslator translator;@</p>
<p dir="auto">and modified the retranslate() like this<br />
@void retranslate()<br />
{<br />
translator.load(path);<br />
qApp-&gt;installTranslator(&amp;translator);<br />
}@</p>
]]></description><link>https://forum.qt.io/post/194629</link><guid isPermaLink="true">https://forum.qt.io/post/194629</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 09 Sep 2013 04:01:10 GMT</pubDate></item><item><title><![CDATA[Reply to QMessageBox  doesn&#x27;t translate the QString[Solved] on Mon, 09 Sep 2013 03:52:45 GMT]]></title><description><![CDATA[<p dir="auto">[quote author="karim24" date="1378697691"]<br />
the problem is that i declared QTranslator ,<br />
load the file and install it inside a function<br />
so when it exits it destroys the transltor<br />
so i removed the definition of the translator<br />
to the constructor then load and install it in the function</p>
<p dir="auto">but don't know why it works fine with rename()[/quote]</p>
<p dir="auto">Check "the documentation of QTranslator":<a href="http://qt-project.org/doc/qt-5.0/qtcore/qtranslator.html" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-5.0/qtcore/qtranslator.html</a> and have a look at the notes:</p>
<p dir="auto">bq. Note that the translator must be created before the application's widgets.</p>
<p dir="auto">Btw the documentation also contains useful examples.</p>
]]></description><link>https://forum.qt.io/post/194626</link><guid isPermaLink="true">https://forum.qt.io/post/194626</guid><dc:creator><![CDATA[leon.anavi]]></dc:creator><pubDate>Mon, 09 Sep 2013 03:52:45 GMT</pubDate></item><item><title><![CDATA[Reply to QMessageBox  doesn&#x27;t translate the QString[Solved] on Mon, 09 Sep 2013 03:34:51 GMT]]></title><description><![CDATA[<p dir="auto">hi,thanks  ,i'm using 5.0.2</p>
<p dir="auto">the problem is that i declared QTranslator ,<br />
load the file and install it inside a function<br />
so when it exits it destroys the transltor<br />
so i removed the definition of the translator<br />
to the constructor then load and install it in the function</p>
<p dir="auto">but don't know why it works fine with rename()</p>
]]></description><link>https://forum.qt.io/post/194627</link><guid isPermaLink="true">https://forum.qt.io/post/194627</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 09 Sep 2013 03:34:51 GMT</pubDate></item><item><title><![CDATA[Reply to QMessageBox  doesn&#x27;t translate the QString[Solved] on Mon, 09 Sep 2013 03:15:14 GMT]]></title><description><![CDATA[<p dir="auto">Which version of Qt are you using? Do you create instance of QTranslator  before the creation of the app's widgets?</p>
]]></description><link>https://forum.qt.io/post/194624</link><guid isPermaLink="true">https://forum.qt.io/post/194624</guid><dc:creator><![CDATA[leon.anavi]]></dc:creator><pubDate>Mon, 09 Sep 2013 03:15:14 GMT</pubDate></item></channel></rss>