View Full Version : Delegates and Signal/Slot

8th October 2008, 16:17
How do I go about connecting delegate signals or delegate slots to other things? I did a quick search on these forums for delegates and didn't find anything, and I've checked over Qt Assistant, also briefly, and cannot seem to find an example.

Does someone know how to go about connect delegates, have an example for me to look at, or know where in the Qt Assistant I need to be looking?

Thank you.

8th October 2008, 17:11
Found the correct example to follow. Check out http://doc.trolltech.com/4.4/itemviews-pixelator.html if you want to see how to connect delegates.

The main point, at least for me, was to create the delegate before hand so you still maintain a reference to it. Don't simply create the delegate when calling setItemDelegate. At that point, the delegate is no different than anything else as far as Signal/Slot is concerned.

31st October 2008, 07:13
i had tried:

MyDelegate *delegate = new MyDelegate;
connect(delegate, SIGNAL(delegate's signal()),
someWidget, SLOT(someWidget's slot()));

in MyDelegate implementation:

//after create the editor
connect (editor, SIGNAL(editor's signal()), this, SLOT(delegate's slot()));

MyDelegate::delegate's slot()
emit delegate's signal();

it makes troubles when being used, however, it works.