Results 1 to 5 of 5

Thread: A problem about i18n

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: A problem about i18n

    Hi,

    there is a difference between [ QTCLASS ] tags and [ CODE ] tags...

    Where did you set the translator? Do you make sure that every widget is making a retranslation after that?

    Quote Originally Posted by FinderCheng View Post
    But I still have a problem: only in one dialog it cannot translate, others are OK...
    With some code we could eventually help. Without it is really hard!

  2. #2
    Join Date
    Sep 2009
    Location
    Nanjing, China
    Posts
    46
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A problem about i18n

    Quote Originally Posted by Lykurg View Post
    Hi,

    there is a difference between [ QTCLASS ] tags and [ CODE ] tags...

    Where did you set the translator? Do you make sure that every widget is making a retranslation after that?



    With some code we could eventually help. Without it is really hard!
    Sorry about the tags but I've no idea how to use it...

    Well, here is my code:

    Qt Code:
    1. // in main.cpp
    2. int main(int argc, char *argv[])
    3. {
    4. QApplication app(argc, argv);
    5.  
    6. // i18n
    7. QTranslator appTranslator;
    8. appTranslator.load(":/pw"); // this is registered in a *.qrc file.
    9. app.installTranslator(&appTranslator);
    10. // Qt's translation
    11. QTranslator qtTranslator;
    12. qtTranslator.load(":/qt");
    13. app.installTranslator(&qtTranslator);
    14.  
    15. app::MainWindow win;
    16. win.showMaximized();
    17.  
    18. return app.exec();
    19. }
    To copy to clipboard, switch view to plain text mode 

    And then in an action slot:

    Qt Code:
    1. // in mainwindow.cpp
    2. /* [private slot]
    3.  * Shows the about dialog.
    4.  */
    5. void app::MainWindow::showAboutDialog()
    6. {
    7. AboutDialog *ad = new AboutDialog();
    8. ad->exec();
    9. }
    To copy to clipboard, switch view to plain text mode 

    and in AboutDialog:

    Qt Code:
    1. // in aboutdialog.cpp
    2. app::AboutDialog::AboutDialog(QWidget *parent)
    3. : QDialog(parent)
    4. {
    5. setWindowFlags(Qt::FramelessWindowHint);
    6. setWindowTitle(tr("About PicWorks"));
    7. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by FinderCheng; 16th October 2009 at 08:03.

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: A problem about i18n

    Well if you can obviously set the [ QTCLASS ] then try to move your mouse a little bit more left to hit the # then you also can set the [ CODE ] tags!

    Make the dialog a children of your mainwindow, then the translation should work.

  4. #4
    Join Date
    Sep 2009
    Location
    Nanjing, China
    Posts
    46
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A problem about i18n

    Quote Originally Posted by Lykurg View Post
    Well if you can obviously set the [ QTCLASS ] then try to move your mouse a little bit more left to hit the # then you also can set the [ CODE ] tags!

    Make the dialog a children of your mainwindow, then the translation should work.
    Thank you! I have edited my post already.

    "a children"? Do you mean:

    Qt Code:
    1. void app::MainWindow::showAboutDialog()
    2. {
    3. AboutDialog *ad = new AboutDialog(this);
    4. ad->exec();
    5. }
    To copy to clipboard, switch view to plain text mode 
    ? If so, I tried this but it still doesn't work. On the other hand, I have almost the same code:
    Qt Code:
    1. // in mainwindow.cpp
    2. void PicWorks::MainWindow::newProWin()
    3. {
    4. ProjectCreateDialog *pcd = new ProjectCreateDialog;
    5. pcd->exec();
    6. }
    To copy to clipboard, switch view to plain text mode 
    This code works well!

Similar Threads

  1. Problem with QAbstractListModel
    By eekhoorn12 in forum Qt Programming
    Replies: 3
    Last Post: 26th August 2009, 14:26
  2. Replies: 1
    Last Post: 23rd April 2009, 09:05
  3. Replies: 19
    Last Post: 3rd April 2009, 23:17
  4. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  5. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.