[commonqt-devel] Comparing QButtons

Stas Boukarev stassats at gmail.com
Mon Sep 16 13:10:09 UTC 2013


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

> 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?
Ok, should be fixed in git.

-- 
With best regards, Stas.



More information about the commonqt-devel mailing list