[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyKDE] Implement MailTo in QT
From:       Keo Sophon <keosophon () khmeros ! info>
Date:       2006-11-16 10:23:37
Message-ID: 200611161723.37461.keosophon () khmeros ! info
[Download RAW message or body]

On Wednesday 15 November 2006 16:36, Andreas Pakulat wrote:
> On 15.11.06 10:18:54, Keo Sophon wrote:
> > I have an about dialog which has author email links. When a user clicks
> > on those links, it will automatically open a default mail-client. Do you
> > know how to implement the code of it? Or do you know any widget and
> > property of that widget that I can use to implement?
>
> With Qt4.2 you could use QDesktopServices and run openUrl with
> mailto:foobar@somename.com.
>
> With Qt4.1/Qt3 you have to write platform-dependent code.
>
> Andreas

I am using Qt4.1. The problem has been solved already. The following is part 
of code:

import sys
from PyQt4 import QtCore, QtGui

class AuthorsTab(QtGui.QWidget):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)        
        fileNameLabel = QtGui.QTextBrowser()
        fileNameLabel.setHtml(self.tr('<br>Hok Kakada (<a 		z	
href="mailto:hokkakada@khmeros.info">hokkakada@khmeros.info</a>)<br><br>Keo 
Sophon (<a 
href="mailto:keosophon@khmeros.info">keosophon@khmeros.info</a>)<br><br>San 
Titvirak (<a 
href="mailto:titvirak@khmeros.info">titvirak@khmeros.info</a>)<br><br>Seth 
Chanratha(<a 
href="mailto:sethchanratha@khmeros.info">sethchanratha@khmeros.info</a>)'))                    
	
	self.connect(fileNameLabel, QtCore.SIGNAL("anchorClicked(const 
QUrl&)"),self.handleLinkClicked)
        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(self.fileNameLabel)
        self.setLayout(mainLayout)

	def handleLinkClicked(self, url):
        '''slot to handle when anchorClicked (an email address), and open a 
webbrowser and a mail client'''
        self.sender().setSource(QtCore.QUrl())
        try:
            import webbrowser
            webbrowser.open(unicode(url.toString()))
            return
        except:
            pass

Thanks.
Phon

_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic