Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7492089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:21:40+00:00 2026-05-29T16:21:40+00:00

#include<QApplication> #include<QTranslator> #include<QObject> #include<QTextCodec> #include<QWidget> int main(int argc, char* argv[]) { QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale()); QApplication app(argc,

  • 0
#include<QApplication>
#include<QTranslator>
#include<QObject>
#include<QTextCodec>
#include<QWidget>

int main(int argc, char* argv[])
{
    QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale());
    QApplication app(argc, argv);

    QTranslator translator;
    translator.load("app_zh_CN.qm");
    app.installTranslator(&translator);

    QWidget widget;
    widget.setWindowTitle(QObject::tr("Hello World!"));
    widget.show();
    return app.exec();
}
SOURCES += \
    main.cpp

TRANSLATIONS += app_zh_CN.ts

The Gui interface is “Hello World!” also.. But in my file.qm is be translate to “你好!”(chinese)…
where is the preblem ? who can help me..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T16:21:41+00:00Added an answer on May 29, 2026 at 4:21 pm

    Your example works for me if I put the .qm file in the “correct” spot. (See below.) Make sure you are doing all the steps:

    1. Run lupdate to create the .ts file.
    2. Do your translation in Linguist and save the .ts file.
    3. Run lrelease to compile the .ts file to a .qm file.
    4. Copy the .qm file to the correct location.

    My guess is that #4 is going bad. The documentation for QTranslator::load states:

    If directory is not specified, the directory of the application’s
    executable is used (i.e., as applicationDirPath()).

    However, I had to put the .qm file in the folder above the executable to get it to work as is. Unless I’m misunderstanding the docs, this is a Qt bug, but one that is simple to workaround. If I explicitly gave the directory as app.applicationDirPath, it worked in the executable folder. You could also specify a separate directory. For example:

    translator.load("app_zh_CN.qm"); works with:

    [MyApp]
      app_zh_CN.qm
      [debug]
        MyApp.exe
    

    translator.load("app_zh_CN.qm", app.applicationDirPath()); works with:

    [MyApp]
      [debug]
        app_zh_CN.qm
        MyApp.exe
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in this code: #include <QApplication> #include <QPushButton> int main(int argc,char *argv[]) { QApplication app(argc,argv);
#include <QtGui> int main (int argc, char* argv[]) { QApplication app(argc, argv); QTextStream cout(stdout,
File name: widgets.c #include <QtGui> int main(int argc, char *argv[]) { QApplication app(argc, argv);
#include <QApplication> #include <QLabel> int main(int argc, char** argv) { QApplication app(argc, argv); QLabel
main: #include QtGui/QApplication #include spc_login.h int main(int argc, char *argv[]) { QApplication a(argc, argv);
I am trying to close an application #include <QtGui/QApplication> #include battle.h int main(int argc,
QApplication::QApplication ( int & argc, char ** argv ) Initializes the window system and
I have the very simple following code: main.cpp #include ui_library_browser.h #include <QtGui/QApplication> #include StartWindow.h
#include <QApplication> #include <QFont> #include <QPushButton> #include <QWidget> class MyWidget : public QWidget {
I tried to write a simple Qt application like this: main.cpp : #include <QApplication>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.