[Qt-interest] [boost::signals] Simplifying deletion responsibility of copied objects passed to QT slots?

Ed Sutton edsutton at gmail.com
Tue Nov 17 17:26:14 CET 2009


I am using boost::signals2 to pass copied objects from my library's worker thread to a QT client GUI.  

While this works well, the QT GUI must delete the copied objects.  This seems wrong to make the GUI have to do this.  Are there any techniques I could use so that the client would not be responsible for the object deletion?

/// The CallbackSynchronizer is used to synchronize the boost:signals2 signal to the Qt GUI thread slot
/// Since CallbackSynchronizer is created on the QMainWindow thread and derived from a QObject, 
/// calling Q_EMIT will post a message on the GUI thread and returns immediately so the GUI can handle the signal asynchronously.
class CallbackSynchronizer : public QObject
{
   Q_OBJECT
public:
   CallbackSynchronizer(QObject * parent ) : QObject(parent) {}

   void onDeviceParameterChangedBoostSignalHandler( Parameter* pParameter) { Q_EMIT onDeviceParameterChanged(pParameter); }

Q_SIGNALS:
   void onDeviceParameterChanged(Parameter* pParameter);
};



Thanks in advance,

-Ed

Multi-threaded 
Red Hat Enterprise 5.x
QT 4x 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091117/88a3a61d/attachment.html 


More information about the Qt-interest-old mailing list