Results 1 to 2 of 2

Thread: Translation and QStringList

  1. #1
    Join Date
    Jan 2024
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Translation and QStringList

    Good evening,

    I am currently trying my hand at a small program with QT and have now encountered the following problem:
    I have created a translation file and specified what I want to translate in the code using "tr("")". In QT Linguist I can also translate these entries successfully.
    Loading the translation also works perfectly.
    However, I have a QStringList to fill a QTableWidget with the header information. There I have also specified the "tr("")", which is also displayed in QLinguist.
    However, no translation is displayed in the window even after recompiling.
    To rule out a direct error, I simply translated a QLabel and set it directly in the code like this: ui.qLabel->setText(tr("Hello"));
    I then "translated" this in QLinguist using lrelease and created the *qm file again and tried it out. This translation is displayed to me.
    I have the following as QStringList:
    Qt Code:
    1. QStringList headerLabels;
    2.  
    3. headerLabels << tr("Order ID") << tr("Order Number") << tr("Line or machine") << tr("Order priority") << tr("Storage location") << tr("Article name") << tr("Article number") << tr("Article Quantity");
    4. headerLabels << tr("Ordered first name") << tr("Orderer last name") << tr("More information") << tr("Cost unit") << tr("Order date");
    To copy to clipboard, switch view to plain text mode 

    and set it with
    Qt Code:
    1. ui.QTableWidghet->setHorizontalHeaderLabels(headerLabels);
    To copy to clipboard, switch view to plain text mode 

    What else could be the reason that the translation is not displayed like this?
    Many thanks for the answers.

    Sevi

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Translation and QStringList

    https://forum.qt.io/topic/153479/tra...ist?lang=en-US

    It is extremely rude to make the same post to multiple forums, and then not follow up to say that your question was answered elsewhere. I wasted many minutes trying to think of a reason why your translation was not working, only to find the link above. Shame on you.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Qt translation
    By jbarrena in forum Qt Programming
    Replies: 19
    Last Post: 16th April 2015, 17:09
  2. translation
    By weixj2003ld in forum Qt Programming
    Replies: 8
    Last Post: 31st May 2010, 01:01
  3. Translation of UI
    By elizabeth.h1 in forum Qt Programming
    Replies: 1
    Last Post: 2nd November 2009, 11:01
  4. Translation
    By merlvingian in forum Qt Programming
    Replies: 1
    Last Post: 14th August 2007, 17:45
  5. Replies: 7
    Last Post: 2nd June 2006, 12:48

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.