PDA

View Full Version : Signal if application is translating?



whitefurrows
23rd September 2009, 11:02
Hi,

i use this Example (http://wiki.qtcentre.org/index.php?title=Dynamic_translation_in_Qt4_applica tions) for dynamic translation.

How can i verify if my applicatin begin and end translating? I have try to send a signal:

application.h

class Application : public QApplication
{
Q_OBJECT

public:
explicit Application(int& argc, char* argv[]);
~Application();

//...

public slots:
static void setLanguage(const QString& locale);
// ...

signals:
static void languageChanging(int);
};

application.cpp

void Application::setLanguage(const QString& locale)
{
emit languageChanging(true);

// remove previous
if (current)
{
removeTranslator(current);
}

// install new
current = translators.value(locale, 0);
if (current)
{
installTranslator(current);
}

emit languageChanging(false);
}

but my compiler say error ... : static member functions do not have 'this' pointers
and i think thats OK but what can i do?

wysota
23rd September 2009, 11:42
Chaning the translation language is done using events so a synchronous code such as your wouldn't make any sense. If you want, you can monitor the application (using event filters) for LanguageChange events. When they will stop comming, it means the changes have propagated themselves.

scascio
23rd September 2009, 13:50
In the case you are about to remove your own translation monitoring, my intervention is useless.

But I can't stop me to tell you that the message your compiler displays is right : installTranslator and removeTranslator are not static, are they?

whitefurrows
12th October 2009, 10:12
Chaning the translation language is done using events so a synchronous code such as your wouldn't make any sense
That’s right.

The problem was my QTreeWidget has send the signal currentItemChanged () if the language changing. But the bug was i have call a function in LanguageChange event. Now it’s all OK.

Thanks for your Help