repos
/
doc
/ annotate_shade
summary
|
shortlog
|
log
|
tree
|
commit
|
commitdiff
|
headdiff
|
annotate
|
headblob
|
headfilediff
|
filehistory
normal
|
plain
|
shade
|
zebra
Lisp syntax highlighting
Annotate for file qt.xml
2009-04-05 tobias
1
<?xml version="1.0"?>
17:58:25 '
2
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
'
3
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
'
4
<chapter id="qt">
'
5
<title>Qt</title>
'
6
<para>
2009-07-22 tobias
7
Besides the <package>:qt</package> there are these packages: with
2009-04-05 tobias
8
<itemizedlist>
2009-08-30 tobias
9
<listitem><para>
14:26:13 '
10
<package>:qt.uitools</package>
'
11
<ulink url="http://doc.trolltech.com/4.5/qtuitools.html">
'
12
QtUiTools</ulink></para></listitem>
'
13
<listitem><para><package>:qt.test</package>
'
14
<ulink url="http://doc.trolltech.com/4.5/qttest.html">
'
15
QtTest</ulink></para></listitem>
'
16
<listitem><para><package>:qt.webkit</package>
'
17
<ulink url="http://doc.trolltech.com/4.5/qtwebkit.html">
'
18
QtWebKit</ulink>
'
19
</para></listitem>
2009-04-05 tobias
20
</itemizedlist>
2009-07-22 tobias
21
which provide bindings for their Qt module.
2010-01-10 tobias
22
Additionally there is the <package>:qt.tests</package> system, containing
08:57:54 '
23
the unit tests and <package>:qt.examples</package> for various examples.
2009-04-05 tobias
24
</para>
17:58:25 '
25
2009-07-06 tobias
26
<section><title>qt:application</title>
2009-04-05 tobias
27
<para>
17:58:25 '
28
The <classname>qt:application</classname> object should created with:
2009-04-07 tobias
29
<macro>qt:with-app</macro>. In its body the event loop can be
2009-04-05 tobias
30
started with <methodname>qt:exec</methodname>.
17:58:25 '
31
</para>
'
32
<example>
'
33
<title>Hello World</title>
'
34
<screenshot>
'
35
<mediaobject>
'
36
<imageobject>
2009-08-30 tobias
37
<imagedata fileref="hello-world.png" format="PNG"/>
2009-04-05 tobias
38
</imageobject>
17:58:25 '
39
</mediaobject>
'
40
</screenshot>
'
41
<programlisting language="lisp">
'
42
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../qt.examples/src/hello-world.lisp" parse="text" />
2009-08-30 tobias
43
</programlisting>
2009-04-05 tobias
44
</example>
2009-06-03 tobias
45
<para>
22:31:34 '
46
Subclasses of <classname>qt:paint-device</classname> (e.g. <classname>qt:widget</classname>) can only be used when
'
47
a <classname>qt:application</classname> instance exists. When there are, for example, <classname>qt:widget</classname> instances
'
48
at the end of <macro>qt:with-app</macro>, they are deleted by the <classname>qt:application</classname> destructor.
'
49
</para>
2009-06-04 tobias
50
<section><title>Interactive Development</title>
21:20:49 '
51
<para>
'
52
The <package>:cl-smoke.repl</package> allows you to start a <classname>qt:application</classname> event loop in the background for
'
53
interactive development in SLIME.
'
54
To start the event loop use <methodname>cl-smoke.repl:start-event-loop-in-background</methodname> (or
'
55
<methodname>cl-smoke.repl:start-event-loop-in-repl</methodname>).
'
56
<footnote>
'
57
<para>
'
58
Currently <code>START-EVENT-LOOP-IN-BACKGROUND</code> is recommended.
'
59
</para>
'
60
</footnote>
'
61
As long as you do not kill the thread or unwind over a foreign function, you should be fine.
'
62
</para>
'
63
</section>
2009-04-05 tobias
64
</section>
17:58:25 '
65
2009-07-06 tobias
66
<section><title>Signal-Slot</title>
2009-04-05 tobias
67
<para>
2009-04-07 tobias
68
<genericfunction>qt:connect</genericfunction> connects a signal to a slot.
2009-04-05 tobias
69
The signal is either a <classname>qt:qsignal</classname> created with
17:58:25 '
70
<methodname>qt:make-signal</methodname> or a C++ signal by using
'
71
<methodname>qt:get-signal</methodname>.
'
72
The slot can be a slot returned by <classname>qt:make-slot</classname>, a function
'
73
or a C++ slot a return from <methodname>qt:get-slot</methodname>.
'
74
</para>
'
75
<example><title>Quit</title>
2009-06-05 tobias
76
<programlisting language="lisp">
2009-04-05 tobias
77
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../qt.examples/src/hello-world-quit.lisp" parse="text" />
17:58:25 '
78
</programlisting>
'
79
</example>
'
80
<para>
'
81
When the argument types for a slot or signal are not specified they are determined when
'
82
the first connection is made. Note that when connecting a <classname>qt:qsignal</classname>
2009-06-04 tobias
83
to a <classname>qt:qslot</classname> at least one must have its arguments types specified. Type specifier <code>T</code>
21:20:49 '
84
allows to pass a Lisp object as is from a Lisp signal to a Lisp slot.
2009-04-05 tobias
85
</para>
17:58:25 '
86
'
87
<para>
'
88
The functionality of the Qt <code>SIGNAL</code> and <code>SLOT</code> macros is
'
89
provided by <methodname>qt:qsignal</methodname> and <methodname>qt:qslot</methodname>.
'
90
</para>
'
91
</section>
'
92
2009-07-06 tobias
93
<section><title>Properties</title>
2009-04-05 tobias
94
<para>
17:58:25 '
95
<classname>qt:object</classname> properties can be accessed with
'
96
<methodname>qt:property</methodname> (setf-able).
'
97
The name of the property can be either a string in C++ style or a symbol in Lisp style.
'
98
</para>
'
99
<informalexample>
2009-06-05 tobias
100
<programlisting language="lisp">
2009-04-05 tobias
101
(let ((object (make-instance '<classname>qt:object</classname>)))
2009-07-22 tobias
102
(setf (<methodname>qt:property</methodname> object 'object-name) "Foo")
2009-08-30 tobias
103
(assert (string= "Foo" (<methodname>qt:property</methodname> object "objectName"))))
2009-04-05 tobias
104
</programlisting>
17:58:25 '
105
</informalexample>
'
106
'
107
</section>
'
108
2009-07-06 tobias
109
<section><title>Variant</title>
2009-04-12 tobias
110
<para>
2009-05-11 tobias
111
A <classname>qt:variant</classname> can be constructed with <methodname>qt:make-variant</methodname>
2009-04-12 tobias
112
or to pass a Lisp object with <methodname>qt:make-lisp-variant</methodname>.
2009-05-11 tobias
113
Its value is returned by <genericfunction>qt:value</genericfunction>.
2009-04-12 tobias
114
</para>
20:56:16 '
115
</section>
2009-04-05 tobias
116
2009-07-06 tobias
117
<section><title>i18n</title>
2009-04-05 tobias
118
<para>
17:58:25 '
119
You can use <methodname>qt:tr</methodname> to translate strings.
'
120
</para>
'
121
<example>
'
122
<title>i18n Hello World</title>
'
123
<screenshot>
'
124
<mediaobject>
'
125
<imageobject>
2009-08-30 tobias
126
<imagedata fileref="i18n-hello-world.png" format="PNG"/>
2009-04-05 tobias
127
</imageobject>
17:58:25 '
128
</mediaobject>
'
129
</screenshot>
'
130
2009-06-05 tobias
131
<programlisting language="lisp">
2009-04-05 tobias
132
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
17:58:25 '
133
href="../qt.examples/src/i18n-hello-world.lisp" parse="text" />
2009-08-30 tobias
134
</programlisting>
2009-04-05 tobias
135
17:58:25 '
136
<formalpara>
'
137
<title><filename>hello-world_de.po</filename></title>
'
138
<para>
'
139
<programlisting language="po">
'
140
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../qt.examples/src/hello-world_de.po" parse="text" />
2009-08-30 tobias
141
</programlisting>
2009-04-05 tobias
142
</para>
17:58:25 '
143
</formalpara>
'
144
</example>
'
145
'
146
<para>
'
147
Gettext is used to extract the i18n strings and compile the message catalog.
'
148
See <filename><ulink url="../qt.examples/src/CMakeLists.txt">CMakeLists.txt</ulink></filename>
'
149
and <filename><ulink url="../qt.examples/src/UseClQti18n.cmake">UseClQti18n.cmake</ulink></filename>
2010-01-10 tobias
150
in the <filename class="directory">src/</filename> directory of <package>:qt.examples</package> on how to do this.
2009-04-05 tobias
151
</para>
17:58:25 '
152
</section>
'
153
2009-07-06 tobias
154
<section><title>Examples</title>
2009-04-05 tobias
155
<para>
17:58:25 '
156
You can run the examples with:
2009-06-05 tobias
157
<programlisting language="lisp">
2010-01-10 tobias
158
(mb:load <package>:qt.examples</package>)
2009-04-07 tobias
159
(<methodname>qt.examples:launcher</methodname>)
2009-04-05 tobias
160
</programlisting>
17:58:25 '
161
</para>
'
162
'
163
<example>
'
164
<title>Repl</title>
'
165
<para>
'
166
Use a <classname>qt:string-list-model</classname> with a <classname>qt:list-view</classname>
'
167
to show evaluated lisp expressions.
'
168
</para>
'
169
<screenshot>
'
170
<mediaobject>
'
171
<imageobject>
2009-08-30 tobias
172
<imagedata fileref="repl.png" format="PNG"/>
2009-04-05 tobias
173
</imageobject>
17:58:25 '
174
</mediaobject>
'
175
</screenshot>
'
176
<programlisting language="lisp">
'
177
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../qt.examples/src/repl.lisp" parse="text" />
2009-08-30 tobias
178
</programlisting>
2009-04-05 tobias
179
</example>
17:58:25 '
180
'
181
<example>
'
182
<title>Class Browser</title>
2010-01-10 tobias
183
<para>Qt Classes browser using <package>:qt.webkit</package> to display the
2009-04-05 tobias
184
API doc and a custom <classname>qt:list-model</classname>
17:58:25 '
185
for the <classname>qt:list-view</classname> of the available classes.
'
186
</para>
'
187
<screenshot>
'
188
<mediaobject>
'
189
<imageobject>
2009-08-30 tobias
190
<imagedata fileref="class-browser.png" format="PNG"/>
2009-04-05 tobias
191
</imageobject>
17:58:25 '
192
</mediaobject>
'
193
</screenshot>
'
194
<programlisting language="lisp">
'
195
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../qt.examples/src/class-browser.lisp" parse="text" />
2009-08-30 tobias
196
</programlisting>
2009-04-05 tobias
197
</example>
17:58:25 '
198
'
199
</section>
'
200
'
201
</chapter>