[commonqt-devel] Comparing QButtons
Rujia Liu
rujia.liu at gmail.com
Fri Sep 13 09:39:02 UTC 2013
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/20130913/e90498f4/attachment.html>
More information about the commonqt-devel
mailing list