Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CommonQt enums and operators

210 views
Skip to first unread message

Eric Eaton

unread,
Oct 5, 2012, 10:31:14 PM10/5/12
to
Hi, I'm a fairly new lisp user and I wish to create a graphical application. CommonQt seems decent but is there really only one page of documentation? In particular I am struggling to figure out how to use enums, they are not a numeric type and I can't find a way to convert them to numbers. Also Qt defines some useful overloaded operators which I can't access.

CL-USER> (defparameter *size* (#_new QSize 4 4))
*SIZE*
CL-USER> (#_operator+= *size* (#_new QSize 3 3))

; in: QT-INTERNAL::|operator14| +=
; (QT::FULL-RESOLVE-THIS +=)
;
; caught WARNING:
; undefined variable: +=
;
; compilation unit finished
; Undefined variable:
; +=
; caught 1 WARNING condition
;
; caught WARNING:
; undefined variable: +=
;
; compilation unit finished
; Undefined variable:
; +=
; caught 1 WARNING condition
; Evaluation aborted on #<UNBOUND-VARIABLE += {10030102E3}>.
CL-USER>

Anyone know if there is a way to accomplish these things?

budden

unread,
Oct 9, 2012, 12:21:02 AM10/9/12
to
Hi! I know nothing about CommonQt, but, some general hints: o know what is *STAR* try (describe '*star*), (describe *star*), use inspector of your lisp IDE etc; Qt reader (#_) _should_ be case sensitive while CL reader is not. Also, it _might_ treat "*" in special way. It is likely to misinterpret *star*, try *STAR* or, better, just give another name to your var:
(defparameter |Star| ...)

(#_operator+= Star (#_new QSize 3 3))

Eric Eaton

unread,
Oct 10, 2012, 2:01:02 AM10/10/12
to
Thanks for your reply.

The reader macro is for executing foreign functions. I am reasonably sure that it only reads the word following it, which is the name of the C++ method to be called. Overloading += in C++ is done by overloading the function named operator+=. So I assumed it would be the same in commonqt.

It appears that there is a function #_operator, and the += is being evaluated normally as the first argument and of course it is unbound. I have to figure out how to use it. There is no documentation which I can find on #_operator.

Eric Eaton

unread,
Oct 10, 2012, 2:08:24 AM10/10/12
to
...and that is because I probably created it when I used the macro.

Eric Eaton

unread,
Oct 10, 2012, 2:29:18 AM10/10/12
to
I did it! By making some trivial modifications to CommonQt. I feel like I've achieved some kind of hacker cred now XD don't spoil this for me. However I have become somewhat disenfranchised with common lisp and commonqt and I'm considering using clojure instead.

Raymond Wiker

unread,
Oct 10, 2012, 12:36:54 PM10/10/12
to
I'm reasonably sure that the reader macro is #_, and the argument is
"operator+=". That is, the reader macro does an FLI lookup of the symbol
named "operator+=", and applies it to the two arguments.

budden

unread,
Oct 11, 2012, 4:58:10 AM10/11/12
to
Hi! In case of "new" #_ also reads QSize so that it can tell it from QSIZE. This is what confused me, sorry for that.

Eric Eaton

unread,
Oct 12, 2012, 2:33:59 AM10/12/12
to
On Wednesday, October 10, 2012 9:36:54 AM UTC-7, Raymond Wiker wrote:
Yes that seems to be its function, but it was stopping before taking the + character from the stream and normal evaluation resumed on +=. The reader macro processed "operator" and interned a corresponding symbol as a side effect. I assumed this meant that the function actually existed. Changing the reader to accept the character + made everything better.
0 new messages