mattrussmill / qcvTouchUp

Simple image viewer and editor for photographs - OpenCV and Qt Widgets application
GNU General Public License v3.0
5 stars 1 forks source link

Change to new signal slot type #40

Closed mattrussmill closed 5 years ago

mattrussmill commented 5 years ago

https://wiki.qt.io/New_Signal_Slot_Syntax

https://stackoverflow.com/questions/32124715/is-it-possible-to-disconnect-all-of-a-qobjects-connections-without-deleting-it

There are at least 2 ways. First, disconnect everything.

disconnect(obj,0,0,0); //or obj->disconnect(); Second. Every connect() returns QMetaObject::Connection which can be copied or moved, so you can save some connections in the list and after some time, just iterate through the list and call disconnect() for every object. Example with one connection:

QMetaObject::Connection m_connection; //… m_connection = QObject::connect(…); //… QObject::disconnect(m_connection); Bonus: no, Qt doesn't support such deep introspection, you can't get list of all connected slots or something another, but in most cases, you don't need this at all. One useful info, that Qt gives you is sender(), pointer to object that sent signal.

mattrussmill commented 5 years ago

https://doc.qt.io/qt-5/signalsandslots-syntaxes.html#

I get no benefit in doing this, and string based syntax are disconnect when an object is destroyed