{"id":541,"date":"2007-07-09T05:35:34","date_gmt":"2007-07-09T12:35:34","guid":{"rendered":"http:\/\/www.gubatron.com\/blog\/2007\/07\/09\/note-about-signals-and-pyqt4\/"},"modified":"2007-07-09T05:35:34","modified_gmt":"2007-07-09T12:35:34","slug":"note-about-signals-and-pyqt4","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/note-about-signals-and-pyqt4\/","title":{"rendered":"Note about Signals and PyQt4."},"content":{"rendered":"<p>I keep making the mistake of sending PyQt_PyObjects instead of sending actual Qt4 objects on signals that are defined by Qt like that.<\/p>\n<p>Bottom line:<\/p>\n<p><strong>If a signal has been defined by Qt, to send Qt objects, just copy and paste it, do not try to override it by exchanging the Qt objects for PyQt_PyObject.<\/strong><\/p>\n<p>This is because PyQt_PyObject is used to represent regular Python objects, therefore, original Qt4 classes will never emit signals under those weird signatures, Qt4 seems to be very strict on how it matches signals.<\/p>\n<p>So when you see something like this on the documentation:<\/p>\n<pre>\nQt Signals\nvoid currentItemChanged (QTreeWidgetItem *,QTreeWidgetItem *)\n<\/pre>\n<p>Define your signal for example like this, and it will work:<\/p>\n<pre>SIGNAL_ITEM_CHANGED = SIGNAL('currentItemChanged (QTreeWidgetItem *,QTreeWidgetItem *)')<\/pre>\n<p>Do not do this, cause it won&#8217;t work:<\/p>\n<pre>SIGNAL_ITEM_CHANGED = SIGNAL('currentItemChanged (PyQt_PyObject, PyQt_PyObject)')<\/pre>\n<p>(Keep in mind PyQt_PyObject is used to represent Python objects only, and its useful only when YOU define and <strong>emit your own signals<\/strong>)<\/p>\n<p>then connect it from a QTreeWidget item (or derived object) to a listener object&#8217;s method like this:<\/p>\n<pre>QObject.connect(myQTree,SIGNAL_ITEM_CHANGED,myListener.onItemChanged)<\/pre>\n<p>Your object&#8217;s listener method should look like this:<\/p>\n<pre>\ndef onItemChanged(self, current, previous):\n  #do what you gotta do, current and previous will be QTreeWidgetItems\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I keep making the mistake of sending PyQt_PyObjects instead of sending actual Qt4 objects on signals that are defined by Qt like that. Bottom line: If a signal has been defined by Qt, to send Qt objects, just copy and paste it, do not try to override it by exchanging the Qt objects for PyQt_PyObject. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[15,30,65,66],"tags":[],"class_list":["post-541","post","type-post","status-publish","format-standard","hentry","category-code","category-geeklife","category-python","category-qt4"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-8J","jetpack-related-posts":[{"id":788,"url":"https:\/\/www.gubatron.com\/blog\/blooploader-06-is-hardy-compatible\/","url_meta":{"origin":541,"position":0},"title":"Blooploader 0.6 is Hardy compatible","author":"gubatron","date":"April 26, 2008","format":false,"excerpt":"Blooploader 0.6 running on Hardy. Currently available only via subversion. For our Linux users, you can safely update to Ubuntu Hardy if the one thing holding your breath was compatibility with the Blooploader. Currently we run the Blooploader in Linux from source, you just need to have installed, Qt4, sip4,\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":470,"url":"https:\/\/www.gubatron.com\/blog\/how-to-build-pyqt4-for-windows\/","url_meta":{"origin":541,"position":1},"title":"How to build PyQt4 for Windows","author":"gubatron","date":"February 23, 2007","format":false,"excerpt":"- Make sure you don't have cygwin or C:devkitPromsysbin in your path, or else your make files can end up trying to run the Makefile using 'sh' and all the makefile we're about to use are meant to run from the windows command line. If for some odd reason you\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":518,"url":"https:\/\/www.gubatron.com\/blog\/creative-qtpyqt-gui-developers-needed\/","url_meta":{"origin":541,"position":2},"title":"Do you dream about coding with Python and Qt4 (PyQt4)? Temboo needs you.","author":"gubatron","date":"May 12, 2007","format":false,"excerpt":"Creative Qt\/PyQt GUI Developers needed About us: Temboo is a New York-based software company. We have developed a new software model which uses a powerful graphical interface to allow non-programmers to quickly build complex workflows enabling disparate databases, web services, and applications to communicate and interact. Think of our technology\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":611,"url":"https:\/\/www.gubatron.com\/blog\/pyqt4-using-qmutex-vs-qmutexlocker\/","url_meta":{"origin":541,"position":3},"title":"PyQt4: Using QMutex vs QMutexLocker.","author":"gubatron","date":"November 25, 2007","format":false,"excerpt":"Here's some code for my future reference on how to use QMutex or QMutexLocker. Lessons Learned: * Use QMutex to protect data, not code. Try not to lock hughe amounts of code within a function with mutex.lock(), mutex.unlock(), if for any reason you forget to release the lock you'll be\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":650,"url":"https:\/\/www.gubatron.com\/blog\/checking-what-pyqt4-version-youre-running\/","url_meta":{"origin":541,"position":4},"title":"Checking what PyQt4 version you&#8217;re running","author":"gubatron","date":"February 1, 2008","format":false,"excerpt":"This is one of those things I tend to forget >>> PyQt4.Qt.qVersion() '4.3.3'","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1946,"url":"https:\/\/www.gubatron.com\/blog\/reviewing-the-nokia-n900-user-and-developer-opinions\/","url_meta":{"origin":541,"position":5},"title":"Reviewing the Nokia N900, User and Developer opinions.","author":"gubatron","date":"July 7, 2010","format":false,"excerpt":"Playing with it from the User Perspective - Virtual keyboard is deactivated by default, not good if you have one hand busy, however I can see why it's this way (the virtual keyboard sucks). When it comes out it covers the entire screen, and the experience with it is not\u2026","rel":"","context":"In &quot;Android&quot;","block_context":{"text":"Android","link":"https:\/\/www.gubatron.com\/blog\/category\/android\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/541","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/comments?post=541"}],"version-history":[{"count":0,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/541\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}