[PyQt] Dialogue box with hyperlink

Sergio Jovani lesergi at gmail.com
Tue Jan 27 21:47:16 GMT 2009


A Dimarts 27 Gener 2009 21:11:22, Darryl Wallace va escriure:
> Hello,
>
> > Has anyone somewhere an example code of a small dialogue box which
> > contains a hyperlink to a web site?
> >
> > I would like to point the user to some web site, in the confirmation
> > dialogue I want to show.
>
> Quick way is to use a QLabel with <qt> </qt> tags in the string and then
> using the standard html for creating a hyperlink:
>
> For example:
>
> dialogLabel = QtGui.QLabel("<qt> Please visit <a href =
> "http://www.google.ca> Google</a>to search.</qt>")
>
> darryl
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Hi, I think that will open any web browser. If you want web browser be opened 
on clicking, you have to add:

dialogLabel = QtGui.QLabel("<qt> Please visit <a href = 
"http://www.google.ca>Google</a>to search.</qt>")
self.connect(dialogLabel, SIGNAL("linkActivated(QString)"), self.OpenURL)

def OpenURL(self, URL):
      QtGui.QDesktopServices().openUrl(QUrl(URL))


Sorry if this is wrong :P


More information about the PyQt mailing list