Results 1 to 5 of 5

Thread: Applying tr() function

  1. #1
    Join Date
    Aug 2011
    Location
    Mumbai
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Applying tr() function

    Hi i'm not able to apply tr() to strings, which are passing to a function. Please can you help?

    Qt Code:
    1. MainWin :: SetMenuBarButton (PdCount,"File", LEFT);
    To copy to clipboard, switch view to plain text mode 

    How to apply tr() function to string "File" ?

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

    Default Re: Applying tr() function

    Whats the problem ?
    Qt Code:
    1. MainWin :: SetMenuBarButton (PdCount,tr("File"), LEFT);
    To copy to clipboard, switch view to plain text mode 
    You can also use QT_TRANSLATE_NOOP in non-member functions and global scope.

  3. #3
    Join Date
    Aug 2011
    Location
    Mumbai
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Applying tr() function

    Hey as tr() function returns the QString. It's passing it to function SetMenuButton, it accepts string as char* so it is giving error of cannot convert from QString to char*.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Applying tr() function

    Then either make that function accept a QString or convert the result of tr to char*.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Applying tr() function

    Quote Originally Posted by prashant.patel View Post
    Hey as tr() function returns the QString. It's passing it to function SetMenuButton, it accepts string as char* so it is giving error of cannot convert from QString to char*.
    It pays to put all the necessary information into your initial question. Stampede answered the question you actually asked. There was no way we could have gleaned your real question from your initial post. Even posting the compiler error message and a few lines before it would have helped. You might get the answer to the real question with an "It doesn't work" post but it will take longer.

Similar Threads

  1. Applying QSqlTableModel to QTableView
    By SykeS in forum Newbie
    Replies: 1
    Last Post: 20th May 2010, 10:34
  2. Applying a consistent background
    By KanadaKid in forum Qt Programming
    Replies: 2
    Last Post: 27th December 2009, 18:56
  3. Resizing problems when applying a layout
    By JimBrown in forum Newbie
    Replies: 1
    Last Post: 21st February 2007, 23:54
  4. Applying fonts to QListWidgetItems
    By L.Marvell in forum Qt Programming
    Replies: 4
    Last Post: 8th May 2006, 11:04

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.