Start QCoreApplication in a native iOS App

130 views Asked by At

What must be done to start a QCoreApplication on iOS in order to use Qt features in a separate library? FYI, the library is mainly written using std C++ but the Bluetooth part uses the well proven and convenience QtBluetooth implementation which i have already used in a lot of applications. I have managed this on Android either by building a service running in a separate process or even start QCoreApplication in a thread. The 2nd approach has still some issues using QtBluetooth, but this is not the point.

When i try to instantiate the QCoreApplication on iOS, the QCoreApplication::instance() is still NULL after creation.

Any advice's or hint's how to manage this?

Thanks in advance.

1

There are 1 answers

0
AD1170 On

Meanwhile, i have found the reason for QCoreApplication::instance() == 0. I have to wait some time after starting the thread that calls QCoreApplication's exec().

 (void) QtConcurrent::run(&runQCoreApplication);

  do {
      this_thread::sleep_for(std::chrono::milliseconds(10));
  } while(!QCoreApplication::instance() && (++to < 300));

 assert(QCoreApplication::instance());