Signal-Slot

qt:connect connects a signal to a slot. The signal is either a qt:qsignal created with qt:make-signal or a C++ signal by using qt:get-signal. The slot can be a slot returned by qt:make-slot, a function or a C++ slot a return from qt:get-slot.

Example 3.2. Quit

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

(in-package :qt.examples)

(defun hello-world-quit ()
  "Quit on push-button click"
  (qt:with-app ()
    (let ((quit (make-instance 'qt:push-button :args '("Quit")))
          (font (make-instance 'qt:font :args (list "Times"
                                                    18
                                                    qt:font.+bold+))))
      (cxx:resize quit 75 30)
      (setf (cxx:font quit) font)
      
      (qt:connect (qt:get-signal quit "pressed()")
      		  #'(lambda ()
                      (format t "About to quit()~%")))
      
      (qt:connect (qt:get-signal quit "clicked()")
                  (qt:get-slot (qt:app) "quit()"))
      (cxx:show quit)
      (qt:exec))))


When the argument types for a slot or signal are not specified they are determined when the first connection is made. Note that when connecting a qt:qsignal to a qt:qslot at least one must have its arguments types specified. Type specifier T allows to pass a Lisp object as is from a Lisp signal to a Lisp slot.

The functionality of the Qt SIGNAL and SLOT macros is provided by qt:qsignal and qt:qslot.