[Qt-interest] Organizing error message strings
John Weeks
john at wavemetrics.com
Tue Apr 6 18:34:01 CEST 2010
Hi, all!
I'm in the process of porting a very large application to Qt. There
are thousands of error messages, and I'm trying to figure out the Qt
way to organize such a large number of strings.
We need:
1) to be able to localize the messages, so it will involve using tr(),
clearly.
2) to retrieve the messages based on an error code. Something like:
QString msg = GetErrorMessage(errorcode)
3) to make it *easy* for developers to add new messages. If it's not
easy, then they won't do it, and we get messages like "Syntax error"
because they just use something that's already there.
I've thought about using something like
QMap<int, QString> messageMap
messageMap.insert(oneErrorCode, tr("You made a mistake"))
It would make look-up easy and fast, but it seems like this approach
requires a lot of initialization at start-up. The problem, obviously,
is entering and storing the strings in a way that makes for easy look-
up.
What have others done to solve this problem? Is there a "Qt Way" to do
this?
Thanks!
Regards, John Weeks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100406/6a6894ba/attachment.html
More information about the Qt-interest-old
mailing list