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. [SOLVED] How to access to UIApplication from a Qt project
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How to access to UIApplication from a Qt project

Scheduled Pinned Locked Moved Mobile and Embedded
5 Posts 3 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.
  • GianlucaG Offline
    GianlucaG Offline
    Gianluca
    wrote on last edited by
    #1

    Dear all,
    I'm using the Qt 5 stable from the git repository (30 may version), and I need to call a method of the UIApplication ... but I don't know to do that for various reasons:

    • Qt projects are C++ based ... UIApplication is an object-C class. How can I call an object-C object method from a C++ method ??
    • How can I add an object-C source file to a Qt project ??

    Can you give me some little example that explain how to call iOS native methods from Qt project ??

    Thanks,
    Gianluca.

    1 Reply Last reply
    0
    • GianlucaG Offline
      GianlucaG Offline
      Gianluca
      wrote on last edited by
      #2

      I did my homework ... and I solved the problem.
      I post here a sketch of the solution:

      create at least two files: myNativeWrapperFunctions.h e myNativeWrapperFunctions.mm; The .h file declare C functions that can be called from C++ and in the .mm file they will implemented using objective-C and accessing to the native iOS frameworks

      simply add the .h to the HEADERS and .mm to SOURCES into the QMake project

      using QMake create the XCode project; XCode knows how to compile .mm files (that's indicate objective-C that can be mixed with C++)

      include the header myNativeWrapperFunctions.h into a C++ source code and call the functions

      That's it.
      Gianluca.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dcole
        wrote on last edited by
        #3

        Hello,

        Can you post exactly what code you used in your objective C files to get access to the UIApplication? Would it be possible to write your own AppDelegate (to handle things like background fetch) and you could set that AppDelegate similar to UIApplicationMain(...)?

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dcole
          wrote on last edited by
          #4

          Actually I was able to get this in a similar fashion. I made a header file that had my C function declaration in it. I imported that to my .mm file. I was then able to call that C function from my C++ source. The implementation of the C function in the .mm can call native ios Objective C

          1 Reply Last reply
          0
          • S Offline
            S Offline
            steno
            wrote on last edited by
            #5

            Were you able to write your own UIApplicationdelegate without any problems?
            [quote author="dcole" date="1395861152"]Hello,

            Can you post exactly what code you used in your objective C files to get access to the UIApplication? Would it be possible to write your own AppDelegate (to handle things like background fetch) and you could set that AppDelegate similar to UIApplicationMain(...)?[/quote]

            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