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. Translation Problem for retranslateUi function

Translation Problem for retranslateUi function

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 4.0k Views
  • 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.
  • C Offline
    C Offline
    cdcc0606
    wrote on last edited by
    #1

    I'm use the fonction QDesktopServices::openUrl(QUrl::fromLocalFile(repertoire_DocAide));

    C 1 Reply Last reply
    0
    • C cdcc0606

      I'm use the fonction QDesktopServices::openUrl(QUrl::fromLocalFile(repertoire_DocAide));

      C Offline
      C Offline
      cdcc0606
      wrote on last edited by
      #2

      My problem is when I use this function retranslateUI, it can translate the sentence. However, when it turns to a header of Qtableview, it didn't translate. I don't know why. Do I need something special to translate for the Qtableview Header?

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

        Hi and welcome to devnet,

        Are you setting the QTableView header content by hand ?

        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
        • C Offline
          C Offline
          cdcc0606
          wrote on last edited by
          #4

          Yes. It's set as following:
          model=new QStandardItemModel(0,6,this);
          model->setHorizontalHeaderItem(0, new QStandardItem(tr("Name")));
          model->setHorizontalHeaderItem(1, new QStandardItem(tr("I/O")));
          model->setHorizontalHeaderItem(2, new QStandardItem(tr("State")));
          model->setHorizontalHeaderItem(3, new QStandardItem(tr("Duration")));
          model->setHorizontalHeaderItem(4, new QStandardItem(tr("Date")));

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

            Then you have to rewrite your code a bit. See the dynamic translation part of the internationalization documentation.

            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
            • C Offline
              C Offline
              cdcc0606
              wrote on last edited by
              #6

              Yes, then I use lupdate and Irelease. Then I translate all the word in tr() to another language in Qt Linguist one by one. All the other words can be translated except for the words of five lines in the above. So i don't know why

              mrjjM 1 Reply Last reply
              0
              • C cdcc0606

                Yes, then I use lupdate and Irelease. Then I translate all the word in tr() to another language in Qt Linguist one by one. All the other words can be translated except for the words of five lines in the above. So i don't know why

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #7

                @cdcc0606
                Hmm, and you do load this translator BEFORE u add items to
                the header ?

                There is no magic going so you need to re-add the items if already added.
                as @SGaist mentions
                http://doc.qt.io/qt-5/internationalization.html#dynamic-translation
                look at the
                void MyWidget::changeEvent(QEvent *event)
                it sets the texts again.
                like
                okPushButton->setText(tr("&OK"));

                This is needed if u change language WHILE the app is up and running.

                Alternatively, just delete model and create again using same function if that an option.

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  cdcc0606
                  wrote on last edited by
                  #8

                  Yeah, you are right. I did as you sais, it works, Thanks.

                  1 Reply Last reply
                  1

                  • Login

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