Results 1 to 7 of 7

Thread: Using tr() in static consts and variables

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanked 342 Times in 324 Posts

    Default Re: Using tr() in static consts and variables

    I don't know if it helps you, but you can always solve it by declaring a helper class instead of string constants, something like:
    Qt Code:
    1. class MyStrings{
    2. public:
    3. static QString TitleSubgenreOther(){
    4. return QObject::tr("Outros" );
    5. }
    6. static QString AnotherStringConstant(){
    7. return QObject::tr("Text to translate");
    8. }
    9. // ...
    10. };
    11.  
    12. ui->category_list->item(2)->setText( MyStrings::TitleSubgenreOther() );
    To copy to clipboard, switch view to plain text mode 
    Last edited by stampede; 16th March 2011 at 23:04. Reason: previous post was edited, remark removed

Similar Threads

  1. Build static QT + static SSL problem.
    By makzimi in forum Qt Programming
    Replies: 3
    Last Post: 23rd April 2012, 23:45
  2. accessing static member variables of one class in another class
    By jasonknight in forum General Programming
    Replies: 5
    Last Post: 6th September 2010, 14:53
  3. how to share variables
    By sksingh73 in forum Newbie
    Replies: 4
    Last Post: 2nd July 2010, 04:54
  4. new problem with simple C++ static variables
    By landonmkelsey in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2008, 05:42
  5. Replies: 4
    Last Post: 14th February 2006, 21:35

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.