summaryrefslogtreecommitdiffstats
path: root/examples/remoteobjects/modelviewserver/doc/src/modelviewserver.qdoc
blob: 789af822bde3527e36ba1869c9134c7b8723b22f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
    \example modelviewserver
    \title Model-View Server

    This is the server-side application that accompanies the
    \l {Model-View Client}.

    This example showcases how to make a simple server program that displays
    and makes changes to a QTreeView which is made available on a Remote
    Objects network.

    \snippet modelviewserver/main.cpp RegistryHost setup

    We start by creating a QRemoteObjectRegistryHost with which other
    Remote Objects will connect, be registered and then be advertised by.
    The model we create can then be easily acquired from the client side by just
    connecting to the registry.

    \snippet modelviewserver/main.cpp Model-creation and role-selection

    Now we have to create the model we need. The exact implementation is
    available in the source code, to which you can navigate by pressing the
    link further down on this page. We also define which \e roles we want to
    expose to the \l{Replica} on the client side.

    \snippet modelviewserver/main.cpp Model-remoting

    Here, we create the QRemoteObjectHost that connects to, and shares all its
    Remote Objects with, the Registry we created earlier. We then start remoting
    the model we just created with the name \c{RemoteModel}. We also pass the
    \e roles argument here.

    \snippet modelviewserver/main.cpp TreeView-creation

    We then display the model with a QTreeView widget.

    \snippet modelviewserver/main.cpp Automated actions

    For the sake of keeping the example light-weight it performs some
    automated actions to affect the model shortly after the server application
    launches. These changes can then be seen on both the server and client side.
    You can also change the text in the fields on the server side and see it
    update on the client side.
*/