1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the documentation of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:FDL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in a
|
---|
14 | ** written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Free Documentation License
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Free
|
---|
18 | ** Documentation License version 1.3 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file included in the packaging of this
|
---|
20 | ** file.
|
---|
21 | **
|
---|
22 | ** If you have questions regarding the use of this file, please contact
|
---|
23 | ** Nokia at [email protected].
|
---|
24 | ** $QT_END_LICENSE$
|
---|
25 | **
|
---|
26 | ****************************************************************************/
|
---|
27 |
|
---|
28 | /*!
|
---|
29 | \page qaxserver-demo-hierarchy.html
|
---|
30 | \title Qt Widget Hierarchy
|
---|
31 |
|
---|
32 | \input examples/activeqt/hierarchy-demo.qdocinc
|
---|
33 | */
|
---|
34 |
|
---|
35 | /*!
|
---|
36 | \example activeqt/hierarchy
|
---|
37 | \title Hierarchy Example (ActiveQt)
|
---|
38 |
|
---|
39 | The Hierarchy example is shows how to write an in-process ActiveX
|
---|
40 | control. The control is a QWidget subclass with child widgets
|
---|
41 | that are accessible as sub-types.
|
---|
42 |
|
---|
43 | \snippet examples/activeqt/hierarchy/objects.h 0
|
---|
44 | The \c QParentWidget class provides slots to create a widget
|
---|
45 | with a name, and to return a pointer to a named widget. The class
|
---|
46 | declaration uses \c Q_CLASSINFO() to provide the COM identifiers for
|
---|
47 | this class.
|
---|
48 |
|
---|
49 | \snippet examples/activeqt/hierarchy/objects.cpp 0
|
---|
50 | The constructor of QParentWidget creates a vertical box layout.
|
---|
51 | New child widgets are automatically added to the layout.
|
---|
52 |
|
---|
53 | \snippet examples/activeqt/hierarchy/objects.cpp 1
|
---|
54 | The \c createSubWidget slot creates a new \c QSubWidget with
|
---|
55 | the name provided in the parameter, and sets the label to that
|
---|
56 | name. The widget is also shown explicitly.
|
---|
57 |
|
---|
58 | \snippet examples/activeqt/hierarchy/objects.cpp 2
|
---|
59 | The \c subWidget slot uses the \c QObject::child() function and
|
---|
60 | returns the first child of type \c QSubWidget that has the requested
|
---|
61 | name.
|
---|
62 |
|
---|
63 | \snippet examples/activeqt/hierarchy/objects.h 1
|
---|
64 | The \c QSubWidget class has a single string-property \c label,
|
---|
65 | and implements the paintEvent to draw the label. The class uses
|
---|
66 | again \c Q_CLASSINFO to provide the COM identifiers, and also sets
|
---|
67 | the \e ToSuperClass attribute to \e QSubWidget, to ensure that only
|
---|
68 | no slots of any superclasses (i.e. QWidget) are exposed.
|
---|
69 |
|
---|
70 | \snippet examples/activeqt/hierarchy/objects.cpp 3
|
---|
71 | \snippet examples/activeqt/hierarchy/objects.cpp 4
|
---|
72 | The implementation of the QSubWidget class is self-explanatory.
|
---|
73 |
|
---|
74 | \snippet examples/activeqt/hierarchy/main.cpp 0
|
---|
75 | The classes are then exported using a QAxFactory. \c QParentWidget is
|
---|
76 | exported as a full class (which can be created ), while \c QSubWidget is
|
---|
77 | only exported as a type, which can only be created indirectly through
|
---|
78 | APIs of \c QParentWidget.
|
---|
79 |
|
---|
80 | To build the example you must first build the QAxServer library.
|
---|
81 | Then run qmake and your make tool in \c examples/activeqt/hierarchy.
|
---|
82 |
|
---|
83 | The \l{qaxserver-demo-hierarchy.html}{demonstration} requires
|
---|
84 | your WebBrowser to support ActiveX controls, and scripting to be
|
---|
85 | enabled.
|
---|
86 |
|
---|
87 | \snippet examples/activeqt/hierarchy-demo.qdocinc 0
|
---|
88 | */
|
---|