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
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@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
Rujia Liu rujia.liu@gmail.com writes:
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!
null-qobject-p
Rujia Liu rujia.liu@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?
It's strange that it's not coalesced, I'll look into it.
But in this case, you can just write:
(case (#_exec message-box) (0 :yes) (1 :no) (2 :cancel))
On Mon, Sep 16, 2013 at 8:53 PM, Stas Boukarev stassats@gmail.com wrote:
It's strange that it's not coalesced, I'll look into it.
But in this case, you can just write:
(case (#_exec message-box) (0 :yes) (1 :no) (2 :cancel))
Thanks! I thought I can lean on exec's return value only for message-box with standard buttons .
Since a teammate is already struggling with this issue for some time, could you first tell me how to extract the pointer's address so that he can write a custom function to compare the address (and later change to a standard way).
- Rujia
-- With best regards, Stas.
Rujia Liu rujia.liu@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.
commonqt-devel@common-lisp.net