Using delegate
-
wrote on 20 Nov 2010, 02:07 last edited by
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?
-
wrote on 20 Nov 2010, 03:35 last edited by
See "Wikipedia":http://en.wikipedia.org/wiki/Delegation_pattern#Complex_C.2B.2B_example . Is that what you mean?
-
wrote on 20 Nov 2010, 13:43 last edited by
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?
-
wrote on 22 Nov 2010, 07:31 last edited by
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:
-
wrote on 22 Nov 2010, 08:03 last edited by
Use "signals & slots":http://doc.trolltech.com/latest/signalsandslots.html as Denis proposed.
-
wrote on 22 Nov 2010, 08:10 last edited by
thanks for help :)
I understand now. we can declare our own signals. ok.
1/6