Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can i show ios contact image in qt?

How can i show ios contact image in qt?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hasti66
    wrote on last edited by
    #1

    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]

    Hasti Ranjkesh

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hasti66
      wrote on last edited by
      #2

      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 )?

      Hasti Ranjkesh

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lqsa
        wrote on last edited by
        #3

        I've used UIImagePNGRepresentation:

        NSData *imageData = UIImagePNGRepresentation(image);
        QImage qImage = QImage::fromData(static_cast<const uchar *>(imageData.bytes), imageData.length);
        
        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved