[PyQt] connection to list view and combo pyqt

David Boddie david at boddie.org.uk
Sun Jan 20 00:26:18 GMT 2008


On Sat Jan 19 13:41:12 GMT 2008, Peter Liedler wrote:

> In my main view I have several connect strings to buttons and
> checkBoxes. They work fine.
> 
>         self.connect(self.checkBoxRipLongest, SIGNAL("clicked()"),
> self.toggleRipLongest)
>         self.connect(self.listViewTitle, SIGNAL("selectionChanged()"),
> self.titleSelected)
>         self.connect(self.comboBoxLanguage, SIGNAL("currentIndexChanged()"),
> self.languageSelected)

Are you sure they all work? The problem below would make me suspicious that
the third one wouldn't work.

> But the connection string to a QComboBox and a QListView do not work.
> What am I doing wrong here?
> 
>         self.connect(self.listViewTitle, SIGNAL("selectionChanged()"),
> self.titleSelected)
>         self.connect(self.comboBoxLanguage, SIGNAL("currentIndexChanged()"),
> self.languageSelected)
> 
> I want to call the self.titleSelected function when another index in the
> list is filled, but obviously the signal is never emitted. (I have put a
> print statement there). Same with the comboBox.

You need to include the argument types in the signal declaration. For
example, currentIndexChanged() is actually available in two forms:

  currentIndexChanged(int)
  currentIndexChanged(const QString&)

I believe you can simplify the second form to

  currentIndexChanged(QString)

if that's the one you want.

Which class provides the selectionChanged() signal?

> Please forgive me to ask such a simple question.

That's what we're here for!

David



More information about the PyQt mailing list