source: trunk/doc/src/snippets/code/doc_src_moc.qdoc@ 728

Last change on this file since 728 was 651, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.2 sources.

File size: 3.3 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 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:LGPL$
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
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42//! [0]
43moc_%.cpp: %.h
44 moc $(DEFINES) $(INCPATH) $< -o $@
45//! [0]
46
47
48//! [1]
49moc_foo.cpp: foo.h
50 moc $(DEFINES) $(INCPATH) $< -o $@
51//! [1]
52
53
54//! [2]
55foo.o: foo.moc
56
57foo.moc: foo.cpp
58 moc $(DEFINES) $(INCPATH) -i $< -o $@
59//! [2]
60
61
62//! [3]
63#include "foo.moc"
64//! [3]
65
66
67//! [4]
68#ifndef Q_MOC_RUN
69 ...
70#endif
71//! [4]
72
73
74//! [5]
75class SomeTemplate<int> : public QFrame
76{
77 Q_OBJECT
78 ...
79
80signals:
81 void mySignal(int);
82};
83//! [5]
84
85
86//! [6]
87// correct
88class SomeClass : public QObject, public OtherClass
89{
90 ...
91};
92//! [6]
93
94
95//! [7]
96class SomeClass : public QObject
97{
98 Q_OBJECT
99
100public slots:
101 void apply(void (*apply)(List *, void *), char *); // WRONG
102};
103//! [7]
104
105
106//! [8]
107typedef void (*ApplyFunction)(List *, void *);
108
109class SomeClass : public QObject
110{
111 Q_OBJECT
112
113public slots:
114 void apply(ApplyFunction, char *);
115};
116//! [8]
117
118
119//! [9]
120class MyClass : public QObject
121{
122 Q_OBJECT
123
124 enum Error {
125 ConnectionRefused,
126 RemoteHostClosed,
127 UnknownError
128 };
129
130signals:
131 void stateChanged(MyClass::Error error);
132};
133//! [9]
134
135
136//! [10]
137#ifdef ultrix
138#define SIGNEDNESS(a) unsigned a
139#else
140#define SIGNEDNESS(a) a
141#endif
142
143class Whatever : public QObject
144{
145 Q_OBJECT
146
147signals:
148 void someSignal(SIGNEDNESS(int));
149};
150//! [10]
151
152
153//! [11]
154class A
155{
156public:
157 class B
158 {
159 Q_OBJECT
160
161 public slots: // WRONG
162 void b();
163 };
164};
165//! [11]
Note: See TracBrowser for help on using the repository browser.