2 <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
7 Besides the <package>:cl-smoke.qt.gui</package> there are these modules:
10 <package>:cl-smoke.qt.uitools</package>
11 <ulink url="http://doc.trolltech.com/4.5/qtuitools.html">
12 QtUiTools</ulink></para></listitem>
13 <listitem><para><package>:cl-smoke.qt.test</package>
14 <ulink url="http://doc.trolltech.com/4.5/qttest.html">
15 QtTest</ulink></para></listitem>
16 <listitem><para><package>:cl-smoke.qt.webkit</package>
17 <ulink url="http://doc.trolltech.com/4.5/qtwebkit.html">
20 <listitem><para><package>:cl-smoke.qt.phonon</package>
21 <ulink url="http://doc.trolltech.com/4.5/phonon.html">
24 <listitem><para><package>:cl-smoke.qt.network</package>
25 The network classes of Qt.
27 <listitem><para><package>:cl-smoke.qt.core</package>
31 which provide bindings for their Qt module. The class names of this modules are in
32 the <package>:qt</package> package. (E.g. Phonon::VideoPlayer is <code>'qt:phonon.video-player</code>
33 and QTest is <code>'qt:test</code>)
36 Additionally there is the <package>:cl-smoke.qt.tests</package> system, containing
37 the unit tests and <package>:cl-smoke.qt.examples</package> for various examples.
40 <section id="qapplication"><title>qt:application</title>
42 The <classname>qt:application</classname> object should created with:
43 <macro>qt:with-app</macro>. In its body the event loop can be
44 started with <methodname>qt:exec</methodname>.
47 <title>Hello World</title>
51 <imagedata fileref="hello-world.png" format="PNG"/>
55 <programlisting language="lisp">
56 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../qt.examples/src/hello-world.lisp" parse="text" />
60 Subclasses of <classname>qt:paint-device</classname> (e.g. <classname>qt:widget</classname>) can only be used when
61 a <classname>qt:application</classname> instance exists. When there are, for example, <classname>qt:widget</classname> instances
62 at the end of <macro>qt:with-app</macro>, they are deleted by the <classname>qt:application</classname> destructor.
65 Custom <methodname>cxx:paint-event</methodname> methods can use <macro>qt:with-painter</macro>
66 to ensure that the <classname>qt:painter</classname> is deactivated at the end of the method.
69 <section><title>Interactive Development</title>
71 The <package>:cl-smoke.repl</package> allows you to start a <classname>qt:application</classname> event loop in the background for
72 interactive development in SLIME.
73 To start the event loop use <methodname>cl-smoke.repl:start-event-loop-in-background</methodname> (or
74 <methodname>cl-smoke.repl:start-event-loop-in-repl</methodname>).
77 Currently <code>START-EVENT-LOOP-IN-BACKGROUND</code> is recommended.
80 As long as you do not kill the thread or unwind over a foreign function, you should be fine.
85 <section id="signal_slot"><title>Signal-Slot</title>
87 <genericfunction>qt:connect</genericfunction> connects a signal to a slot.
88 The signal is either a <classname>qt:qsignal</classname> created with
89 <methodname>qt:make-signal</methodname> or a C++ signal by using
90 <methodname>qt:get-signal</methodname>.
91 The slot can be a slot returned by <classname>qt:make-slot</classname>, a function
92 or a C++ slot a return from <methodname>qt:get-slot</methodname>.
94 <example><title>Quit</title>
95 <programlisting language="lisp">
96 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../qt.examples/src/hello-world-quit.lisp" parse="text" />
100 When the argument types for a slot or signal are not specified they are determined when
101 the first connection is made. Note that when connecting a <classname>qt:qsignal</classname>
102 to a <classname>qt:qslot</classname> at least one must have its arguments types specified. Type specifier <code>T</code>
103 allows to pass a Lisp object as is from a Lisp signal to a Lisp slot.
107 The functionality of the Qt <code>SIGNAL</code> and <code>SLOT</code> macros is
108 provided by <methodname>qt:qsignal</methodname> and <methodname>qt:qslot</methodname>.
112 <section id="properties"><title>Properties</title>
114 <classname>qt:object</classname> properties can be accessed with
115 <methodname>qt:property</methodname> (setf-able).
116 The name of the property can be either a string in C++ style or a symbol in Lisp style.
117 The predefined Qt properties can be accessed with symbols in the keyword package.
120 <programlisting language="lisp">
121 (let ((object (make-instance '<classname>qt:object</classname>)))
122 (setf (<methodname>qt:property</methodname> object :object-name) "Foo")
123 (assert (string= "Foo" (<methodname>qt:property</methodname> object "objectName"))))
129 <section id="variant"><title>Variant</title>
131 A <classname>qt:variant</classname> can be constructed with <methodname>qt:make-variant</methodname>
132 or to pass a Lisp object with <methodname>qt:make-lisp-variant</methodname>.
133 Its value is returned by <genericfunction>qt:value</genericfunction>.
137 <section id="i18n"><title>i18n</title>
139 You can use <methodname>qt:tr</methodname> to translate strings.
142 <title>i18n Hello World</title>
146 <imagedata fileref="i18n-hello-world.png" format="PNG"/>
151 <programlisting language="lisp">
152 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
153 href="../qt.examples/src/i18n-hello-world.lisp" parse="text" />
157 <title><filename>hello-world_de.po</filename></title>
159 <programlisting language="po">
160 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../qt.examples/src/hello-world_de.po" parse="text" />
167 Gettext is used to extract the i18n strings and compile the message catalog.
168 See <filename><ulink url="../qt.examples/src/CMakeLists.txt">CMakeLists.txt</ulink></filename>
169 and <filename><ulink url="../qt.examples/src/UseClQti18n.cmake">UseClQti18n.cmake</ulink></filename>
170 in the <filename class="directory">src/</filename> directory of <package>:cl-smoke.qt.examples</package> on how to do this.
174 <section id="qt_examples"><title>Examples</title>
176 You can run the examples with:
177 <programlisting language="lisp">
178 (asdf:oos 'asdf:load-op <package>:cl-smoke.qt.examples</package>)
179 (<methodname>qt.examples:launcher</methodname>)
186 Use a <classname>qt:string-list-model</classname> with a <classname>qt:list-view</classname>
187 to show evaluated lisp expressions.
192 <imagedata fileref="repl.png" format="PNG"/>
196 <programlisting language="lisp">
197 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../qt.examples/src/repl.lisp" parse="text" />
202 <title>Class Browser</title>
203 <para>Qt Classes browser using <package>:cl-smoke.qt.webkit</package> to display the
204 API doc and a custom <classname>qt:list-model</classname>
205 for the <classname>qt:list-view</classname> of the available classes.
210 <imagedata fileref="class-browser.png" format="PNG"/>
214 <programlisting language="lisp">
215 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../qt.examples/src/class-browser.lisp" parse="text" />
221 <section id="opengl"><title>OpenGL</title>
223 For OpenGL a binding is needed (e.g.:
224 <ulink url="http://common-lisp.net/project/cl-opengl/">cl-opengl</ulink>).
226 <example><title>Origami</title>
228 <ulink url="http://tobias.rautenkranz.ch/darcsweb/darcsweb.cgi?r=cl-smoke/qt.examples;a=tree;f=/src/origami">Origami</ulink>
229 draws a pleated hyperbolic paraboloid using the method described in
230 <ulink url="http://arxiv.org/abs/0906.4747">(Non)existence of Pleated Folds: How Paper Folds Between Creases</ulink>
234 <videodata fileref='origami.ogg'/>
240 <ulink url="http://axiom-wiki.newsynthesis.org/FrontPage">Axiom</ulink> is needed to generate the lisp source to that
241 calculates the vertices.