[Qt-interest] Applying RightToLeft for whole application
Tony Rietwyk
tony.rietwyk at rightsoft.com.au
Wed May 18 17:41:07 CEST 2011
Hi,
Did you include the Qt arabic translations in :/lang/ar ? Just having Yes and No translated is not enough, it needs to match the context specified in the QMessageBox code.
Does the locale name message appear in arabic correctly? A screen shot might help.
Tony.
-----Original Message-----
Sent: Thursday, 19 May 2011 00:38 AM
On 18/05/2011 04:32 م, admin at mbnoimi.net wrote:
Hi guys,
For applying right to left layout I use setLayoutDirection function for each container (QWdiget, QMainWindow... etc) in some cases (I faced it) it's really exhausted procedure so I'm wondering:
Can I applying layout direction for whole application by single line?
PS
I tried to use setLayoutDirection with QApplication varialble but it didn't work!
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
a.setLayoutDirection(Qt::RightToLeft);
w.show();
return a.exec();
}
There is out code solution which passing -reverse argument. Can I use -reverse somehow inside my code for geting its benefit?
Sorry, It's working well when I use setLayoutDirection in main() but it's not when I use it from MainWindow... see this slot:
void MainWindow::on_actionInstant_Translation_triggered()
{
QTranslator translator;
if(qApp->isRightToLeft())
{
if(!translator.load(":/lang/en"))
qDebug()<<QObject::tr("Couldn't load English language");
// this->setLayoutDirection(Qt::LeftToRight);
qApp->setLayoutDirection(Qt::LeftToRight);
}
else
{
if(!translator.load(":/lang/ar"))
qDebug()<<QObject::tr("Couldn't load Arabic language");
// this->setLayoutDirection(Qt::RightToLeft);
QLocale::setDefault(QLocale(QLocale::Arabic, QLocale::SyrianArabRepublic));
qApp->setLayoutDirection(Qt::RightToLeft);
}
qApp->installTranslator(&translator);
ui->retranslateUi(this);
QLocale local;
/**
BUG: QMessageBox buttons didn't appear in Arabic for Arabic local language $ RTL layout
*/
QMessageBox::information(this, "", QLocale::languageToString(local.language()), QMessageBox::Yes|QMessageBox::No);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110519/05725669/attachment.html
More information about the Qt-interest-old
mailing list