[PyQt] QFileDialog , filterSelected() problem

Phil Thompson phil at riverbankcomputing.com
Tue Jun 10 09:39:59 BST 2008


On Tuesday 10 June 2008 9:13:47 am sa6113 wrote:
> I'm using code like the following,
>
>      s = "Raw data file (*.raw)";
>      fd = QFileDialog (self)
>      fileName = fd.getOpenFileName("","Text files (*.txt);;All files (*)" ,
> self, "Open file")
>
>      self.connect(fd, SIGNAL(filterSelected(const QString &)),
> fd,self.filter )
>
>      def filter(self,f)
>         QMessageBox.information(self, "Selected Filter", f )

    self.connect(fd, SIGNAL(filterSelected(const QString &)), self.filter)

> I want to show a MessageBox to the user that inform s/he about which filter
> that selected,
> but it doesn't work, it seems that SIGNAL won't be emitted , What is the
> problem?
>
> also I can't use :
> self.connect(fd, SIGNAL(filterSelected(const QString &)), self,
> SLOT(setFilter(s)))
>
> the error is :
> No such slot QFileDialog::setFilter(s)

    self.connect(fd, SIGNAL(filterSelected(const QString &)), self.setFilter)

> Would you please help me ?
> Looking forward,

Phil


More information about the PyQt mailing list