Results 1 to 5 of 5

Thread: not able to receive SIGNAL

  1. #1
    Join Date
    Sep 2010
    Posts
    11
    Thanks
    3
    Qt products
    Platforms
    MacOS X Unix/X11 Windows

    Default not able to receive SIGNAL

    hi,

    i've got a QWidget with some lineedits, a "cancel" button and an "apply" button.

    i connect the "clicked()" signal to the QWidget like this:

    Qt Code:
    1. self.connect(self.__apply_button, QtCore.SIGNAL("clicked()"), QtCore.SIGNAL("apply_clicked"))
    2. self.connect(self.__cancel_button, QtCore.SIGNAL("clicked()"), QtCore.SIGNAL("cancel_clicked"))
    To copy to clipboard, switch view to plain text mode 

    when ths signal is sent, i want to forward a signal to the parent of the QWidget (__mywidget) which is of the type QObject.

    at the parent i listen to the signals of my QWidget

    Qt Code:
    1. self.connect(self.__mywidget, QtCore.SIGNAL("apply_clicked"), self.__handle_apply)
    2. self.connect(self.__mywidget, QtCore.SIGNAL("cancel_clicked"), self.__handle_cancel)
    To copy to clipboard, switch view to plain text mode 

    the problem is, i never receive the signal from __mywidget. __handle_apply and __handle_cancel are custom slots of course

    i also tried to emit a signal manually from __mywidget but it doesn't work either.

    NOTE: please consider this is python syntax. should be syntactically ok.

    any ideas? what do i have to consider when connecting to signals?
    i'm completely clueless, what im doing wrong there.

    thanks, chris

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: not able to receive SIGNAL

    QObject does not have a "apply_clicked" signal. You should subclass QObject and introduce the method in the subclass.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2010
    Posts
    11
    Thanks
    3
    Qt products
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: not able to receive SIGNAL

    i'm sorry, i did not clearly mention, that __mywidget is a subclass of QWidget and the parent is a subclass of QObject

    apply_clicked is my own defined signal. i don't know the exact differences between Qt for c++ and PyQt when it comes to signals, but it is possible to define your own signals that way

    any other ideas?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: not able to receive SIGNAL

    There are SLOT macros missing in your connect statements.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Sep 2010
    Posts
    11
    Thanks
    3
    Qt products
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: not able to receive SIGNAL

    i'm sorry - there are no slot macros in pyqt (at least i don't know them ) - the connect statements are totally correct for pyqt.

    the problem was the way i did instantiate the parent class QObject. i'm kinda new to python and there are obviously several ways to inherit from classes. although i had access to inherited methods ... the SIGNAL handling did not work when inherited like this:

    Qt Code:
    1. class ViewController(QtCore.QObject):
    2.  
    3. def __init__(self, parent=None):
    4. QtCore.QObject.__init__(self)
    To copy to clipboard, switch view to plain text mode 

    a strange thing is, that it already works in another class when i instantiate this way but i cannot get it working here ...

    -> changing to this is the solution of the problem:
    Qt Code:
    1. class ViewController(QtCore.QObject):
    2.  
    3. def __init__(self, parent=None):
    4. super(ViewController, self).__init__(parent)
    To copy to clipboard, switch view to plain text mode 

    so the problem is solved ... at least the SIGNAL thing.
    thanks anyway

Similar Threads

  1. How to signal when a Qwidget receive focus
    By franco.amato in forum Qt Programming
    Replies: 5
    Last Post: 5th February 2016, 17:33
  2. Qextserialport receive
    By Max123 in forum Newbie
    Replies: 2
    Last Post: 28th March 2010, 23:40
  3. Replies: 6
    Last Post: 3rd September 2008, 15:27
  4. Receive file over TCP
    By winarko in forum Qt Programming
    Replies: 18
    Last Post: 29th May 2008, 18:25
  5. Replies: 0
    Last Post: 23rd September 2007, 12:54

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.