• [^] # Re: slot sur une fonction

    Posté par . En réponse au message Akonadi, comprend pas :-/. Évalué à 3.

    Comme le dit Octabrain il fait créer l'objet de l'application avant le reste et comme le dit le site de KDE QApplication n'est pas substituable à KApplication !

    Comme ça ça a l'air de marcher :

    #!/usr/bin/python2
    from PyKDE4.akonadi import *
    from PyKDE4.kdecore import *
    from PyQt4.QtCore import *
    from PyKDE4.kdeui import KApplication
    import sys
    def fetch(job):
     print "plop"
     if job.error(): print job.errorString()
     else: print "prout"
    appName = "MyApp"
    catalog = ""
    programName = ki18n("")
    version = "0.1"
    description = ki18n("")
    license = KAboutData.License_GPL
    copyright = ki18n("")
    text = ki18n("")
    homePage = ""
    bugEmail = ""
    aboutData = KAboutData (appName, catalog, programName, version, description,
     license, copyright, text, homePage, bugEmail)
    KCmdLineArgs.init (sys.argv, aboutData)
    app = KApplication()
    mimeTypes = QStringList()
    mimeTypes.append("application/x-vnd.akonadi.calendar.todo")
    mimeTypes.append("application/x-vnd.akonadi.calendar.event")
    scope = Akonadi.CollectionFetchScope()
    scope.setContentMimeTypes(mimeTypes)
    fetchJob = Akonadi.CollectionFetchJob(Akonadi.Collection.root(), Akonadi.CollectionFetchJob.Recursive)
    fetchJob.setFetchScope(scope)
    fetchJob.result.connect(fetch)
    fetchJob.start()
    app.exec_()