summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/internationalization/i18n.qdoc7
-rw-r--r--doc/src/snippets/code/doc_src_i18n.cpp11
2 files changed, 17 insertions, 1 deletions
diff --git a/doc/src/internationalization/i18n.qdoc b/doc/src/internationalization/i18n.qdoc
index ede019c1e..1d3e9f99f 100644
--- a/doc/src/internationalization/i18n.qdoc
+++ b/doc/src/internationalization/i18n.qdoc
@@ -852,10 +852,15 @@
reimplement the widget's \l{QWidget::changeEvent()}{changeEvent()} function
to check whether the event is a \l{QEvent::LanguageChange}{LanguageChange}
event and update the text displayed by widgets using the \l{QObject::tr()}
- {tr()} function in the usual way. For example:
+ {tr()} function. For example:
\snippet snippets/code/doc_src_i18n.cpp 12
+ When using Qt Designer UI files (.ui) and \c uic, you can read the new
+ translation files and call \c ui.retranslateUi(this) directly:
+
+ \snippet snippets/code/doc_src_i18n.cpp 17
+
To pass on other change events, call the default implementation of the
function.
diff --git a/doc/src/snippets/code/doc_src_i18n.cpp b/doc/src/snippets/code/doc_src_i18n.cpp
index 717c387fd..e488321d8 100644
--- a/doc/src/snippets/code/doc_src_i18n.cpp
+++ b/doc/src/snippets/code/doc_src_i18n.cpp
@@ -188,3 +188,14 @@ public:
}
};
//! [16]
+
+
+//! [17]
+void MyWidget::changeEvent(QEvent *event)
+{
+ if (event->type() == QEvent::LanguageChange) {
+ ui.retranslateUi(this);
+ } else
+ QWidget::changeEvent(event);
+}
+//! [17]