Skip to content

Join between classes

Hamed Masafi edited this page Dec 21, 2019 · 2 revisions

How to join classes

In master class

    NUT_DECLARE_CHILD_TABLE(Score, scores)

In this case scores if of type TableSet. so it should be initialized in constructor.

Post::Post(QObject *parent) : Table(parent),
    m_id(0), m_title(""),
    m_scores(new TableSet<Score>(this))
{

}

NUT_IMPLEMENT_CHILD_TABLE(Post, Score, scores)

The macro NUT_IMPLEMENT_CHILD_TABLE will be put codes of child class implement

In slave class

In header:

    //                      Class type   key type     name     read method      write method
    NUT_FOREIGN_KEY_DECLARE(Post,        int,         post,    post,            setPost)

In source:

    NUT_FOREIGN_KEY_IMPLEMENT(Score, Post, int, post, post, setPost)

More example

Master class sample:

Slave class sample:

Table of contents

Clone this wiki locally