O'Reilly logo

Game Programming using Qt 5 Beginner's Guide - Second Edition by Lorenz Haas, Witold Wysota, Pavel Strakhov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

What just happened?

The class that was implemented can be used for bidirectional conversion between Item instances and a QByteArray object, which contains the object data in the JSON format. We didn't do any error checking here; instead, we relied on Qt's rule that an error results in a sensible default value.

What if you want to perform error checking? The most straightforward solution in this case is to use exceptions, as they will automatically propagate from the multiple nested calls to the caller's location. Ensure that you catch any exceptions you throw, or the application will terminate. A more Qt-like solution is to create a bool *ok argument in all methods (including internal ones) and set the boolean value to false in case of any ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required