I want to show the user a warning QMessageBox with a link inside. This is relatively easy, I just need to make sure I set the RichText text format on the message box and the QMessageBox
setup does the rest. However, I would also like to close the message box (as in some-sort-of-call-to done()
) if the user clicks on the link - the semantic being that the user acknowledged the message and made a decision.
The problem: QMessageBox
hides the linkActivated
signal coming from its inner QLabel
(which is used to store the text).
I thought I could extend the QMessageBox
class and do this very ugly hack in the constructor:
QLabel *lbl = findChild<QLabel*>(QString("qt_msgbox_label"));
assert(lbl != NULL);
connect(lbl, SIGNAL(linkActivated(const QString&)), this, SLOT(handle_link_activation(const QString&)));
but although the label found with findChild
is not null, and the "qt_msgbox_label"
is definitely correct (c/p ed from the source), and there is no "no such signal/slot" message, my slot never gets called when I click the link.
I d like to avoid writing my own QDialog
which would mimic the QMessageBox
behavior. Does anyone have any idea on how I can catch that signal?