Access all dialogs of application
-
Hi there
I've been developing a multilingual application that could change ui language in runtime. I do this:
@
namespace Global
{
extern Application* application;
extern QList<QWidget*> allDialogs;
}@
and connected change language slots to corresponding slots (they call Global::application->installTranslator... ).
everything works: all of dialogs are translated during runtime.
Also directions of all dialog need to be changed for RTL languages like Arabic and Persian. Couldn't find a way to access all dialogs and main windows of an application, so I add them in their ctors to a global QList<QWidget*> and setLayoutDirection(Qt::RightToLeft) there.Is there a better way to access all dialogs and their children and children of children and .... ?
-
Thank you. It works well.
I write a subclass of QDialog and add retranslateUI method to it. that method simply calls ui->retranslateUi(). I subclass all my dialogs from it. iterating over children of main window of type DialogProxy*, program calls that method:
@
QList<DialogProxy*> list = this->findChildren<DialogProxy*>();
for(int i=0; i<list.size(); i++)
list.at(i)->retraslateUI();
@
when clicking on the change language menu item all open dialogs are translated.