[PyQt] How to open QWhatsThis hyperlinks in an external browser?
dsdale24 at gmail.com
Fri Dec 5 20:51:24 GMT 2014
Perfect, thank you. I'm doing something along the lines of:
temp = WhatsThisUrlLoader()
for k, v in self.__dict__.items():
if isinstance(v, QWidget):
def eventFilter(self, e):
if e.type() == QEvent.WhatsThisClicked:
On Fri, Dec 5, 2014 at 10:27 AM, Florian Bruhin <me at the-compiler.org> wrote:
> * Darren Dale <dsdale24 at gmail.com> [2014-12-05 10:06:53 -0500]:
> > For many widgets in a GUI I'm developing, I would like to add What's This
> > documentation that contain links to online Sphinx-based documentation. In
> > Designer, I can add whatsThis documentation with hyperlinks, but clicking
> > the link in the resulting GUI doesn't do anything. Based on the
> > documentation for QWhatsThis (
> > http://pyqt.sourceforge.net/Docs/PyQt4/qwhatsthis.html), and some
> > online (http://qt-project.org/forums/viewthread/34565), my
> understanding is
> > that I would need to reimplement the `event` method for each widget,
> > perhaps along the lines of:
> > def event(self, e):
> > try:
> > href = e.href()
> > import webbrowser
> > webbrowser.open_new_tab(href)
> > except AttributeError:
> > pass
> > super(self.__class__, self).event(e)
> You'd also have to check if the event actually is a QWhatsThisEvent
> (e.type() == QEvent.WhatsThisClicked). Then the try/except is
> probably unnecessary as well.
> > On the other hand, I'm using Designer and uic.loadUi, so the prospect of
> > subclassing numerous widgets is... I don't know how I would do it. And
> > prospect of rewriting the entire GUI programmatically to support this
> > rather obvious use case makes me suspect I'm just doing it wrong.
> > Is it possible to plug in to PyQt's uic/loadUi routines to define the
> > `event` method for every widget that gets instantiated? Or is there
> > approach I have overlooked?
> You could use an event filter on the QApplication to intercept all
> WhatsThisClicked events and react on them.
>  http://qt-project.org/doc/qt-4.8/eventsandfilters.html#event-filters
> http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
> GPG 0xFD55A072 | http://the-compiler.org/pubkey.asc
> I love long mails! | http://email.is-not-s.ms/
> PyQt mailing list PyQt at riverbankcomputing.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PyQt