Chapter 3. Qt

Table of Contents

qt:application
Interactive Development
Signal-Slot
Properties
Variant
i18n
Examples
OpenGL

Besides the :cl-smoke.qt.gui there are these modules:

which provide bindings for their Qt module. The class names of this modules are in the :qt package. (E.g. Phonon::VideoPlayer is 'qt:phonon.video-player and QTest is 'qt:test)

Additionally there is the :cl-smoke.qt.tests system, containing the unit tests and :cl-smoke.qt.examples for various examples.

qt:application

The qt:application object should created with: qt:with-app. In its body the event loop can be started with qt:exec.

Example 3.1. Hello World

;;; Copyright 2009 Tobias Rautenkranz
;;; License: X11 license

(in-package :qt.examples)

(defun hello-world ()
  "Hello world"
  (qt:with-app ()
    (let ((widget (make-instance 'qt:push-button :args '("Hello world"))))
      (cxx:show widget)
      (qt:exec))))


Subclasses of qt:paint-device (e.g. qt:widget) can only be used when a qt:application instance exists. When there are, for example, qt:widget instances at the end of qt:with-app, they are deleted by the qt:application destructor.

Custom cxx:paint-event methods can use qt:with-painter to ensure that the qt:painter is deactivated at the end of the method.

Interactive Development

The :cl-smoke.repl allows you to start a qt:application event loop in the background for interactive development in SLIME. To start the event loop use cl-smoke.repl:start-event-loop-in-background (or cl-smoke.repl:start-event-loop-in-repl). [4] As long as you do not kill the thread or unwind over a foreign function, you should be fine.



[4] Currently START-EVENT-LOOP-IN-BACKGROUND is recommended.