[PyKDE] Problems with auto-connect and QAbstractButton.clicked()

Andreas Pakulat apaku at gmx.de
Thu Jan 26 15:49:26 GMT 2006


I have 2 problems with QAbstractButton.clicked and auto-connection:

1. the auto-connected slot gets called twice, I have no idea why

2. according to Qt4 docs clicked has a boolean argument which I cannot
use with the autoconnected slot.

The attached files include a minimal example.


Your lucky number is 3552664958674928.  Watch for it everywhere.
-------------- next part --------------
<ui version="4.0" >
 <widget class="QWidget" name="Form" >
  <property name="geometry" >
  <property name="windowTitle" >
  <layout class="QHBoxLayout" >
   <property name="margin" >
   <property name="spacing" >
    <widget class="QPushButton" name="pushButton" >
     <property name="text" >
-------------- next part --------------
import sys
import cStringIO
import os
from PyQt4 import QtCore, QtGui
# this time, we use the code generator
from PyQt4.uic import Compiler

def compileToType(filename):
    code_string = cStringIO.StringIO()
    widget_info = Compiler.compileUi(file(filename, "r"), code_string)
    # the buffer code_string now contains the generated Python code
    widget_module = compile(code_string.getvalue(), filename, "exec")
    exec widget_module
    return locals()[widget_info["uiclass"]]

class myWidget(QtGui.QWidget, compileToType("test.ui")):
	def __init__(self):

        # according to Qt4 docs clicked takes a boolean argument
	def on_pushButton_clicked(self):
		print "test"

if __name__ == "__main__":
 	app =  QtGui.QApplication(sys.argv)
	w = myWidget()

More information about the PyQt mailing list