[PySide] User defined signals and slots

Hedieh Ebrahimi hedieh.ebrahimi at amphos21.com
Tue Oct 29 15:27:50 CET 2013


Hi all,

In my User Interface, I have many pushButtons. When one of these
pushButtons is clicked, a function is called that will open a QFileDialog
that will let you browse for a file as below:

 def askforfile(self):

        curFileName=self.ui.X_Vel_lineEdit.text()
        (fileName, _selectedFilter) =
QtGui.QFileDialog.getOpenFileName(self,
filter="*.txt;;*.*",viewMode="Detail")


As I have so many of these browse buttons, I was thinking to edit the "
askforfile" method so that it would take the QEditLine that is operating on
as an argument.

Then I understood that Clicked which is a pushButton predefined thing,
doesn´t accept arguments and I can not have the following line in my code.


self.ui.X_Vel_pushButton.pushed.connect(self.askforfileBTN(self.ui.X_Vel_lineEdit))

as the self.askforfileBTN(self.ui.X_Vel_lineEdit)) has
self.ui.X_Vel_lineEdit as its argument.

, so finally I defined the following signal and then i connected it.

pushed=QtCore.Signal(self.ui.X_Vel_lineEdit)

self.connect(self.ui.X_Vel_pushButton, QtCore.SIGNAL("pushed()"),
self.askforfileBTN(self.ui.X_Vel_lineEdit))

and now what happens is that the the fileDialog opens even before the main
Window opens and before i even click the push button.

Any ideas on what I might be doing wrong?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20131029/264f97b2/attachment.html>


More information about the PySide mailing list