Unsolved Who generates QEvent::LocaleChange?
-
Hi,
I am just wondering where the somewhat global
QEvent::LocaleChange
originates from. For example, theQEvent::LanguageChange
is generated when installing or removing translators from the application. But I could not find any place in the Qt sources where aQEvent::LocaleChange
is actually being posted ...So where do
QEvent::LocaleChange
events normally come from?Thanks!
Yours,
Kama -
@Kamajii said in Who generates QEvent::LocaleChange?:
But I could not find any place in the Qt sources where a QEvent::LocaleChange is actually being posted
Basically in
QWidget::setLocale
https://code.woboq.org/qt5/qtbase/src/widgets/kernel/qwidget.cpp.html#5957 -
Hi!
The only place in Qt Base where that event is sent is in src/widgets/kernel/qwidget.cpp.
BTW, you can do a recursive full-text search on a directory with
cd your_code_directory grep -rwn './' -e 'QEvent::LocaleChange'
-
@VRonin ninja!
-
This post is deleted! -
@VRonin okay, maybe i was just blind
-
@Wieland That's exactly what I did :-)
But I spared the
QEvent::
part because I wasn't sure if the event is (maybe) sent from insideQEvent
itself so the scope qualification wouldn't be present. -
@Kamajii It doesn't matter who sent the event, LocaleChange is declared in QEvent (so is part of QEvent class) - that's why you need to prefix it with QEvent.
-
@jsulm You're certainly mistaken or we are misunderstanding each other.
If theLocaleChange
was posted from within theQEvent
class itself (or any derived class) it possibly would not have been prefixed with the scopeQEvent
.
As I did not find any other place where the event is posted I finally even considered this unlikely option in my search.Anyway, does that mean that Qt applications actually do not respond to locale changes in the desktop environment?
-
@Kamajii said in Who generates QEvent::LocaleChange?:
misunderstanding each other.
Yes you (plural) did. It's not important though so let's skip over it
does that mean that Qt applications actually do not respond to locale changes in the desktop environment?
Absolutely not, why would you think this?
-
@VRonin said in Who generates QEvent::LocaleChange?:
Yes you (plural) did. It's not important though so let's skip over it
Surely. But I fixed my wording in my last answer - I'm not a native speaker and it sounded a little rude even to me afterwards - sorry for that.
@VRonin said in Who generates QEvent::LocaleChange?:
Absolutely not, why would you think this?
Not sure if I want it.
However, to me the documentation sounds like so. For theQEvent::LocaleChange
event it says, "The system locale has changed." (sic). As I cannot recall any way to change the system locale with Qt I inferred that Qt will eventually post the event automatically.
Maybe it is just the wording that is a little misleading (to me)? -
Hi
It also sends on desktop, so one way of handling it isvoid MainWindow::changeEvent(QEvent *event) { if (event->type() == QEvent::LocaleChange) { QString qmPath = directoryOf("translations").absolutePath(); appTranslator.load("callcenter_" + QLocale::system().name(), qmPath); qtTranslator.load("qt_" + QLocale::system().name(), qmPath); // this is generated when you use UI files. if you hand code, you must provide this function yourself // to set all texts again retranslateUi(); <<< } QMainWindow::changeEvent(event); }
http://www.informit.com/articles/article.aspx?p=1405555&seqNum=3