Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Mix QT with objective-c to develope an ios application
Forum Updated to NodeBB v4.3 + New Features

Mix QT with objective-c to develope an ios application

Scheduled Pinned Locked Moved Mobile and Embedded
5 Posts 2 Posters 3.6k Views 1 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 want to implement an ios application with qt. I've installed qt on mac and i want to use objective-c code in qt c++. to fetch iphone address book, then i want to use it in qt c++. how can i do that? how can i embed objective-c code in qt c++? are there a way like androidextra for ios?

    Hasti Ranjkesh

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

      I found a solution : http://qt-project.org/forums/viewthread/40299

      "Create a C++ header that contains the function you’ll use to invoke the native file selection dialog.

      Then write a mm file that implements the function calling the Objective-C classes/code you need.

      Add the mm file to the OBJECTIVE_SOURCES variable."

      Hasti Ranjkesh

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        You can also take a look at Qt's code to see example on how to do that cleanly

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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

          Hi,
          Thanks
          For use objective-c class in qt c++, I've used the code from this link: http://stackoverflow.com/questions/1061005/calling-objective-c-method-from-c-method

          //mainwindow.h
          public:
          int MyObjectDoSomethingWith(void *myObjectInstance, void *parameter);
          void someMethod(void *myObjectInstance, void *parameter);

          //MyObject.h
          #import <Foundation/Foundation.h>

          @interface MyObject : NSObject

          // The Objective-C member function you want to call from C++

          • (int) doSomethingWith:(void *) aParameter;

          @end

          //mainwindow.cpp
          void MainWindow::someMethod(void *objectiveCObject , void *aParameter)
          {
          int ret = MyObjectDoSomethingWith(objectiveCObject ,aParameter )
          }

          //MyObject.mm
          #import "MyObject.h"

          @implementation MyObject

          // C "trampoline" function to invoke Objective-C method
          int MyObjectDoSomethingWith (void *self, void *aParameter)
          {
          // Call the Objective-C method using Objective-C syntax
          return [(id) self doSomethingWith:aParameter];
          }

          • (int) doSomethingWith:(void *) aParameter
            {
            // The Objective-C function you wanted to call from C++.
            // do work here..
            return 21 ; // half of 42
            }
            @end

          //.pro
          OBJECTIVE_SOURCES += MyObject.mm
          LIBS += -framework Foundation
          ...

          Afetr building, i got these errors:
          symbol(s) not found for architecture x86_64
          linker command failed with exit code 1 (use -v to see invocation)

          I use qt5.3 on mac, please help me.

          Hasti Ranjkesh

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

            I found a solution. Please go to : http://qt-project.org/forums/viewthread/48250/

            Hasti Ranjkesh

            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