[solved] Translation on the fly crashes
-
Hi,
What does a run trough the debugger tells you ?
Are you sure all the pointers your are using are valid ?
-
Are you sure translator is valid ?
-
@MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
translator = new QTranslator(0);@I can translate the whole program while being on MainWindow. As soon as I go into a widget, I can no longer translate the program. It crashes :s
-
That's in the MainWindow, how do you do it in your widget ?
-
I emit a signal from the widget which is then caught by the main window :
WIDGET :
@void ui_sys_settings::languageToEn()
{
emit toEnglish();
}void ui_sys_settings::languageToFr()
{
emit toFrench();
}@MAINWINDOW :
@connect(sysSettings,SIGNAL(toEnglish()),this,SLOT(changeToEnglish()));
connect(sysSettings,SIGNAL(toFrench()),this,SLOT(changeToFrench()));void MainWindow::changeToFrench()
{
if(!translator->isEmpty())
qApp->removeTranslator(translator);
}void MainWindow::changeToEnglish()
{
if(!translator->isEmpty())
qApp->removeTranslator(translator);translator->load("dcl_en",QApplication::applicationDirPath()); qApp->installTranslator(translator);
}@
-
Are you sure you need to re-install the translator ?
-
Strange...
Could you post/share a minimal compilable example that shows the problem ? -
Rather the minimal code that reproduce the crash
-
Indeed, but with only pieces of code, I can't try to reproduce the crash.
-
You can also use a service like "pastbin":http://pastebin.com/
-
Only what is needed to build and trigger the crash