PDA

View Full Version : QComboBox Signals doesn't invoke the called function



ladiesfinger
28th December 2010, 14:48
I'm using PyQt .

I had two comboboxes . First combobox has seven commands as text . Each command has its own options . ( i'll put options in the second combobox )

if user clicks commands combobox , then only the second combobox should appear with appropriate options loaded on it.

To do this action , i've tried to connect the 'changing' event with the function that implements the second combobox .

But , the function doesn't get invoked ..... ( i can't figure out what problem is )


i'll paste the code here :


self.connect(self.command,QtCore.SIGNAL('editTextC hanged()'),self.optionopen)


called function :



def optionopen(self):
self.optionlab=QtGui.QLabel('Option:',self)
self.loc.addWidget(self.optionlab,4,10)
self.option=QtGui.QComboBox(self)
self.loc.addWidget(self.option,4,14)
self.option.insertItems(268,list)
self.setLayout(self.loc)


I've tried out following functions:

changeEvent()
activated()
currentIndexChanged()
and finally
editTextChanged()

Plz , help me out .....
Any suggestions are welcome....

high_flyer
28th December 2010, 14:51
self.connect(self.command,QtCore.SIGNAL('editTextC hanged()'),self.optionopen)
I haven't done anything with python, so I don't know anything about it syntax, but where is the SLOT() parameter?
if optionopen() is a slot, it should be defined as such, and also in the connect statement it should be given as QtCore.SLOT().

ladiesfinger
28th December 2010, 14:54
usually , i didn't give SLOT() parameter in python ( in c++ , i did give )

I've implemented a push button previously , connected it to a function processimg as:


self.connect(self.process,QtCore.SIGNAL('clicked() '),self.processimg)

It worked superb ....

but this function doesn't get invoked .

proper function for event changing of a combobox ?

high_flyer
28th December 2010, 15:01
all the signals you mentioned have a prameter, yet in your code your are connecting a signal without parameters, which does not exist - look in your console or debug output for any runtim signal/slot warnings.
Also, I would use the signal: void currentIndexChanged ( const QString & text ).

ladiesfinger
28th December 2010, 16:20
As you mentioned , i tried to give parameters to the signal

TypeError: C++ type 'argument' is not supported as a slot argument type


( i think i should figure out a way to provide slots in python)

Well , thank u for your instant replies :o

AlexSudnik
28th December 2010, 17:03
Hey,

What does connection operation return?I mean,maybe there is a problem with the slot execution rather then with connection establishment. Try to place a print("Slot is called") or smth. to check it...

ladiesfinger
30th December 2010, 16:20
thank u alex, that was a good idea .
And i have done that => The slot itself is not called

It is a mistake in calling statement . Still can't figure out

Added after 40 minutes:

i Got itttttttttt.

It's simple :


self.connect(self.command,QtCore.SIGNAL('activated (QString)'),self.optionopen)

Just passed QString as a parameter . ( When i used QtCore.SLOT('optionopen(self)') , it didn't work . )