Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] how to translate model dialogs in addition to mainwindow?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] how to translate model dialogs in addition to mainwindow?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 757 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    loudking
    wrote on last edited by
    #1

    Hi all, my qt application could switch languages in mainwindow. But the 'tr' is not working in modal dialogs. Could anybody do me a help? Thanks in advance.

    TS file and QM file already contain correct translations.

    @
    /* Modal Dialog Header File */
    class DTRuleDialog : public QDialog
    {
    Q_OBJECT
    public:
    explicit DTRuleDialog(QWidget *parent = 0);
    QLabel *labelFollow;
    }
    @

    @
    /* Modal Dialog CPP File */
    DTRuleDialog::DTRuleDialog(QWidget *parent) :
    QDialog(parent)
    {
    labelFollow = new QLabel(tr("Follow"));
    }
    @

    @
    /* MainWindow CPP File */

    DTMainWindow::DTMainWindow()
    {
    btnCustomize = new QPushButton("");
    connect(btnCustomize, SIGNAL(clicked()), SLOT(rule()));
    }

    void DTMainWindow::rules()
    {
    DTRuleDialog *ruleDialog = new DTRuleDialog(this);
    ruleDialog->exec();
    }
    @

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Maybe a silly question, but are you loading the translation file properly in your application ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • L Offline
        L Offline
        loudking
        wrote on last edited by
        #3

        OK. Problem is solved by having different context name for different widgets in TS file.

        @
        <context>
        <name>MainWindow</name>
        blabla
        </context>
        <context>
        <name>ModalDiaglog</name>
        blabla
        </context>
        @

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved