Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learn Qt 5

You're reading from   Learn Qt 5 Build modern, responsive cross-platform desktop applications with Qt, C++, and QML

Arrow left icon
Product type Paperback
Published in Feb 2018
Publisher Packt
ISBN-13 9781788478854
Length 346 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Nicholas Sherriff Nicholas Sherriff
Author Profile Icon Nicholas Sherriff
Nicholas Sherriff
Arrow right icon
View More author details
Toc

Entities

As we have a lot of functionality we want to share across our data models, we'll implement an Entity base class. We need to be able to represent parent/child relationships so that a client can have supply and billing addresses. We also need to support collections of entities for our contacts and appointments. Finally, each entity hierarchy must be able to serialize itself to and from a JSON object.

Create a new class Entity in cm-lib/source/data.

entity.h:

#ifndef ENTITY_H
#define ENTITY_H
#include <map>
#include <QObject> #include <QScopedPointer>
#include <cm-lib_global.h> #include <data/data-decorator.h>
namespace cm { namespace data {
class CMLIBSHARED_EXPORT Entity : public QObject { Q_OBJECT
public: Entity(QObject* parent = nullptr, const QString& key =
"SomeEntityKey...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image