Using delegate
-
Hi,
I am new in Qt C++. I want to use a delegate feature as in Objective-C. How can I use such a thing?
-
See "Wikipedia":http://en.wikipedia.org/wiki/Delegation_pattern#Complex_C.2B.2B_example . Is that what you mean?
-
Don't know how ObjC implements delegation, but if we are speaking about OO delegation mechanism, then maybe you can do what you need with signal-slots mechanism?
-
I have IconDownloader class. it downloads image asyncranously and i want it to trigger owner class's method.
@Objective-C
- (void)showImage:
{
IconDownloader *iconDownloader = [[IconDownloader alloc] init];
iconDownloader.imageUrl = "http://www.a.com./image.jpg";
iconDownloader.delegate = self;
[iconDownloader startDownload];
[iconDownloader release];
}
// called by our IconDownloader class when an icon is ready to be displayed
- (void)appImageDidLoad:(NSIndexPath *)indexPath
{
....
}
@
- (void)showImage:
-
Use "signals & slots":http://doc.trolltech.com/latest/signalsandslots.html as Denis proposed.
-
thanks for help :)
I understand now. we can declare our own signals. ok.