Results 1 to 7 of 7

Thread: QComboBox Signals doesn't invoke the called function

  1. #1
    Join Date
    Aug 2010
    Location
    Chennai
    Posts
    21
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QComboBox Signals doesn't invoke the called function

    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 :
    Qt Code:
    1. self.connect(self.command,QtCore.SIGNAL('editTextChanged()'),self.optionopen)
    To copy to clipboard, switch view to plain text mode 

    called function :

    Qt Code:
    1. def optionopen(self):
    2. self.optionlab=QtGui.QLabel('Option:',self)
    3. self.loc.addWidget(self.optionlab,4,10)
    4. self.option=QtGui.QComboBox(self)
    5. self.loc.addWidget(self.option,4,14)
    6. self.option.insertItems(268,list)
    7. self.setLayout(self.loc)
    To copy to clipboard, switch view to plain text mode 

    I've tried out following functions:

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

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

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox Signals doesn't invoke the called function

    Qt Code:
    1. self.connect(self.command,QtCore.SIGNAL('editTextChanged()'),self.optionopen)
    To copy to clipboard, switch view to plain text mode 
    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().
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. The following user says thank you to high_flyer for this useful post:

    ladiesfinger (28th December 2010)

  4. #3
    Join Date
    Aug 2010
    Location
    Chennai
    Posts
    21
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox Signals doesn't invoke the called function

    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:

    Qt Code:
    1. self.connect(self.process,QtCore.SIGNAL('clicked()'),self.processimg)
    To copy to clipboard, switch view to plain text mode 

    It worked superb ....

    but this function doesn't get invoked .

    proper function for event changing of a combobox ?
    Last edited by ladiesfinger; 28th December 2010 at 16:01.

  5. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox Signals doesn't invoke the called function

    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 ).
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. The following user says thank you to high_flyer for this useful post:

    ladiesfinger (28th December 2010)

  7. #5
    Join Date
    Aug 2010
    Location
    Chennai
    Posts
    21
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation Re: QComboBox Signals doesn't invoke the called function

    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

  8. #6
    Join Date
    Dec 2010
    Location
    Russia
    Posts
    83
    Thanks
    1
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QComboBox Signals doesn't invoke the called function

    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...

  9. #7
    Join Date
    Aug 2010
    Location
    Chennai
    Posts
    21
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox Signals doesn't invoke the called function

    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 :

    Qt Code:
    1. self.connect(self.command,QtCore.SIGNAL('activated(QString)'),self.optionopen)
    To copy to clipboard, switch view to plain text mode 

    Just passed QString as a parameter . ( When i used QtCore.SLOT('optionopen(self)') , it didn't work . )
    Last edited by ladiesfinger; 30th December 2010 at 17:20.

Similar Threads

  1. Slot doesn't get called
    By waynew in forum Qt Programming
    Replies: 7
    Last Post: 18th April 2010, 14:34
  2. How come this slot doesn't get called every second?
    By ShaChris23 in forum Qt Programming
    Replies: 2
    Last Post: 6th November 2009, 00:41
  3. Replies: 0
    Last Post: 17th September 2009, 11:40
  4. QThread::start() doesn't invoke run() method
    By seim in forum Qt Programming
    Replies: 2
    Last Post: 5th February 2009, 18:09
  5. commitData doesn't seem to be called...
    By tone in forum Qt Programming
    Replies: 7
    Last Post: 10th September 2008, 15:42

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.