How can i show ios contact image in qt?
-
Hi, I've used qt 5.3 to develop an ios application. I've extracted addressbook details like firstname, lastname, phone numbers and image of each contact by the objective-c codes:
@
NSData contactImageData = nil;
UIImage image = nil;
if(ABPersonHasImageData(person))
{
if(&ABPersonCopyImageDataWithFormat != nil)
{
//ios >= 4.1
contactImageData = (NSData) ABPersonCopyImageDataWithFormat(person,kABPersonImageFormatThumbnail);
}
else
{
//ios < 4.1
contactImageData = (NSData) ABPersonCopyImageData(person);
}
}
else
{
NSLog(@"No Image");
}if(contactImageData != nil) { image = [UIImage imageWithData:contactImageData]; }
@
Now my question is how can i convert UIImage (or NSData) to QLabel or QPixmap or QImage to show contact image in qt cpp side?
[edit: added missing coding tags @ SGaist]
-
any idea?
Can i use NSData bytes that returns a pointer to the receiver’s contents ((const void *)bytes) for create a QImage with QImage::QImage ( uchar * data, int width, int height, Format format )? -
I've used UIImagePNGRepresentation:
NSData *imageData = UIImagePNGRepresentation(image); QImage qImage = QImage::fromData(static_cast<const uchar *>(imageData.bytes), imageData.length);