[commonqt-devel] Re: Comparing QButtons

Rujia Liu rujia.liu at gmail.com
Mon Sep 16 03:24:22 UTC 2013


In particular, how to know whether a pointer is actually NULL? I noticed
that it's not converted to CL's nil, but a wrapper that contains the NULL
pointer inside.

Of course I can hack it by checking whether (format nil "~A" the-pointer)
contains the substring null, but I think there should be a better solution.

Thanks in advance!


On Fri, Sep 13, 2013 at 5:39 PM, Rujia Liu <rujia.liu at gmail.com> wrote:

> Hi!
>
> I've create a QMessageBox and tried to use clickedButton() to determine
> which button is clicked, like illustrated in QMessageBox::clickedButton
> ()'s document.
>
> My function:
>
> (defun yes-no-cancel-dialog (text informative-text yes-text no-text
> cancel-text)
>     (with-objects ((message-box (#_new QMessageBox)))
>         (#_setText message-box text)
>         (#_setInformativeText message-box informative-text)
>         (let ((yes-button (#_addButton message-box yes-text
> (#_QMessageBox::YesRole)))
>               (no-button (#_addButton message-box no-text
> (#_QMessageBox::NoRole)))
>               (cancel-button (#_addButton message-box cancel-text
> (#_QMessageBox::RejectRole)))
>               (clicked-button))
>             (#_exec message-box)
>             (setf clicked-button (#_clickedButton message-box))
>             (format t "clicked:~A~%" (#_clickedButton message-box))
>             (format t "clicked:~A~%" yes-button)
>             (format t "clicked:~A~%" no-button)
>             (format t "clicked:~A~%" cancel-button)
>             (cond ((eq clicked-button yes-button) :yes)
>                   ((eq clicked-button no-button) :no)
>                   ((eq clicked-button cancel-button) :cancel)
>                   (t nil)))))
>
> When I click "yes" button, I can see something like:
>
> clicked:#<QPushButton 0x02003E18>
> clicked:#<QPushButton 0x02003E18>
> clicked:#<QPushButton 0x02004098>
> clicked:#<QPushButton 0x02004428>
>
> I tried eq, eql, equal and equalp, none of them return t when comparing
> clicked-button with yes-button. What can I do to compare two pointers?
>
> Thanks in advance.
>
> - Rujia
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/commonqt-devel/attachments/20130916/ef50a115/attachment.html>


More information about the commonqt-devel mailing list