[PyKDE] (no subject)

Phil Thompson phil at riverbankcomputing.co.uk
Thu Feb 26 09:35:01 GMT 2004


On Thursday 26 February 2004 06:53, ankarp at charter.net wrote:
> Hello to all,
>
> While playing with PyQt, I attempted to reimplement
> in it a few C++ examples from the Qt distribution.
> Working on the example from
>
> <...>/qt-devel-XXX/examples/mdi
>
> (which compiles and runs properly in C++) I encountered
> the following problem, shown here in the most minimal
> form for illustration:
>
> ##########################
>
> import sys
> from qt import *
>
> class ApplicationWindow(QMainWindow):
>     def __init__(self):
>         QMainWindow.__init__(self,None,
>              "example application main window",
>               Qt.WDestructiveClose)
>         self.fileTools = QToolBar(self, "file operations")
>         self.addDockWindow(self.fileTools,
>              "File operations",
>               QMainWindow.DockTop, True)
>         openIcon = QPixmap([]) # empty pixmap, for brevity
>         openIconSet = QIconSet(openIcon)
>         fileOpen = QToolButton(openIconSet, "Open File",
>               None, self, SLOT("load()"), self.fileTools,
>               "open file" )
>
>     def load(self):
>         print "DEBUG: called load()..."
>
>
> def main(argv):
>     app=QApplication(sys.argv)
>     window=ApplicationWindow()
>     window.show()
>     app.connect(app, SIGNAL('lastWindowClosed()'), app,
>          SLOT('quit()'))
>     app.exec_loop()
>
> if __name__=="__main__":
>     main(sys.argv)
>
> ##########################################
>
> When running it I get a window show up fine, but
> also the following messages:
>
> bash$ python mdimin.py
> QObject::connect: No such slot QMainWindow::load()

The clue is in the message - there is no such slot. There is a Python slot 
(ie. a Python callable) ApplicationWindow.load().

> QObject::connect:  (sender name:   'open file')
> QObject::connect:  (receiver name: 'example application main window')
>
> In other words, self is not recognized as having type
> ApplicationWindow. Does anybody know how to fix this?
>
> The same error occurs when I try to connect to the slot
> in other ways, for example, while still in ApplicationWindow.__init__():
>
> file = QPopupMenu(self)
> id = file.insertItem( openIconSet, "&Open...",
>                       self, SLOT("load()"),
>                       Qt.CTRL+Qt.Key_O )

Instead of...

    self, SLOT("load()"),

...do...

    self.load,

Phil




More information about the PyQt mailing list