PDA

View Full Version : Applying tr() function



prashant.patel
7th September 2011, 06:31
Hi i'm not able to apply tr() to strings, which are passing to a function. Please can you help?


MainWin :: SetMenuBarButton (PdCount,"File", LEFT);

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

stampede
7th September 2011, 07:25
Whats the problem ?

MainWin :: SetMenuBarButton (PdCount,tr("File"), LEFT);
You can also use QT_TRANSLATE_NOOP in non-member functions and global scope.

prashant.patel
7th September 2011, 13:14
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*.

wysota
7th September 2011, 13:52
Then either make that function accept a QString or convert the result of tr to char*.

ChrisW67
7th September 2011, 22:48
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.