[commonqt-devel] Re: Question abot CommonQt examples

Stas Boukarev stassats at gmail.com
Wed Sep 11 19:31:58 UTC 2013


Rujia Liu <rujia.liu at gmail.com> writes:

> I removed the "new eventloop" stuff from tutorial-14 and changed it
> according to qt-conv, something like (omitted unwind-protect and hide):
>
>   (setf *qapp* (make-qapplication))
>   (let ((window (test)))
>      (#_exec *qapp*)))
>
> Then it worked.
Indeed. But it looks like this sequence of code is repeated in all the
projects. So, I decided to make it easier.
Exported a new variable, qt:*qapplication*. Calling make-qapplication is
now equivalent to doing
(or *qapp* (setf *qapp* (make-qapplication))).
QApplication can be instantiated only once anyway, there's no reason to
repeat it in each project.

Moreover, I also added a with-main-window macro. The main function of
the tutorial is now simply

(with-main-window (window (make-instance 'game-board))
  (#_setGeometry window 100 100 500 355))
which expands into
(progn
 (make-qapplication)
 (with-objects ((window (make-instance 'game-board)))
   (#_setGeometry window 100 100 500 355)
   (#_show window)
   (#_exec *qapplication*)))


> Great! Now I think I can end my "evaluation process" now and start to write
> the real applications (one new project, one project that has a ltk version
> - but tk has some limitations so we'd like to port it to commonqt).
Good to hear that. Feel free to ask any questions, the documentation may
be lacking in some aspects.
I updated it to mention the above changes. And also added a description
on how to better connect signals and some additional information about
method overrides. You may want to reread sections
http://common-lisp.net/project/commonqt/#id106138
and
http://common-lisp.net/project/commonqt/#id106256

-- 
With best regards, Stas.



More information about the commonqt-devel mailing list