Logo Questions Linux Laravel Mysql Ubuntu Git Menu

Qt Whats This using a link/anchor





How can I put an anchor <a> into a whatsThis for a widget an intercept it being clicked?

I know about linkActivated in a QLabel, or linkClicked in a QTextBrowser, but I don't know how I can do the same thing with a Whats This text.

To be clear, I want to know if this is possible without interception help events and managing the WhatsThis mechanism on my own.

like image 909
edA-qa mort-ora-y Avatar asked Feb 24 '23 01:02

edA-qa mort-ora-y

2 Answers

If I understand your question, it's that you want to know if there is a SIGNAL() for this. There does not appear to be. Seems you have to watch for the QWhatsThisClickedEvent by deriving your own Widget class or with some kind of global filter:


FYI, the actual point where the QWhatsThisClickedEvent is emitted in the Qt sources is here:


like image 62
HostileFork says dont trust SE Avatar answered Mar 08 '23 06:03

HostileFork says dont trust SE

HostileFork's answer is pretty much on the money. One simple approach that may work unless you have widgets which catch WhatsThisClicked events themselves is to listen for WhatsThisClicked events in your main window's widget. The code is pretty simple, something like the following:

bool  MyMainWindow::event(QEvent* ev)
    if (ev->type() == QEvent::WhatsThisClicked)
        QWhatsThisClickedEvent* whatsThisEvent = dynamic_cast<QWhatsThisClickedEvent*>(ev);
        return true;
    return QMainWindow::event(ev);
like image 42
Craig Scott Avatar answered Mar 08 '23 07:03

Craig Scott