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. error: no member named 'create' in 'QThread'
Forum Updated to NodeBB v4.3 + New Features

error: no member named 'create' in 'QThread'

Scheduled Pinned Locked Moved Solved Mobile and Embedded
7 Posts 2 Posters 2.8k 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.
  • TuniDevT Offline
    TuniDevT Offline
    TuniDev
    wrote on last edited by
    #1

    Greeting every one,

    I do compile this code for windows and it work good, but for Android it show me this warring error.

    void Handler_Transaction::saveObject(bool modeThread)
    {
    if(modeThread == true)
    {
    QThread *thread = QThread::create(
    this{ this->saveObject(false);}
    );
    thread->start();

        return;
    }
    

    }

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

      Are you running at least Qt 5.10 on the android build system? QThread::create() is a pretty new function added in 5.10.

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      TuniDevT 1 Reply Last reply
      2
      • A ambershark

        Are you running at least Qt 5.10 on the android build system? QThread::create() is a pretty new function added in 5.10.

        TuniDevT Offline
        TuniDevT Offline
        TuniDev
        wrote on last edited by
        #3

        @ambershark yes, the prove that's work for windows.

        A 1 Reply Last reply
        0
        • TuniDevT TuniDev

          @ambershark yes, the prove that's work for windows.

          A Offline
          A Offline
          ambershark
          wrote on last edited by
          #4

          @TuniDev Are you using C++17 on your android compiler? This function is also only available there according to the docs.. My guess here is no since I don't even know of a stable c++17 compiler for android.

          My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

          TuniDevT 1 Reply Last reply
          1
          • A ambershark

            @TuniDev Are you using C++17 on your android compiler? This function is also only available there according to the docs.. My guess here is no since I don't even know of a stable c++17 compiler for android.

            TuniDevT Offline
            TuniDevT Offline
            TuniDev
            wrote on last edited by
            #5

            @ambershark
            Yes, I use it.

            QT += sql core gui quick
            CONFIG += c++17
            android: QT += androidextras

            //*****************************************************

            I guess they did not implement yet for Android.
            Is there any other solution to run my function in separate thread, using this class as argument ?

            A 1 Reply Last reply
            0
            • TuniDevT TuniDev

              @ambershark
              Yes, I use it.

              QT += sql core gui quick
              CONFIG += c++17
              android: QT += androidextras

              //*****************************************************

              I guess they did not implement yet for Android.
              Is there any other solution to run my function in separate thread, using this class as argument ?

              A Offline
              A Offline
              ambershark
              wrote on last edited by
              #6

              @TuniDev Yea just adding CONFIG += C++17 doesn't mean the target compiler will actually support it. In this case the g++ you are using for android probably doesn't. I could be wrong though, easy to test if you were curious..

              There are a ton of ways to run in a new thread. If you'd like a simple fire and forget function to run concurrently then I would just use c++11's threading. You can of course use QThread, but you will need to use the signal/slot method or a derived QThread.

              Using just plain c++ you could do:

              std::thread myThread([&](YourObject *whatever) { whatever->yourFunc(); }, this);
              

              ** No guarantees this works, didn't test it or compile... check std c++ docs in case I'm remembering wrong. I don't use c++ threads much since I have QThread most of the time. :)

              I would verify that my assumption of missing c++17 support is true (I'm pretty sure that's the problem though), and if so make sure you at least have c++11 on that compiler. If not I recommend upgrading your compiler. The above code requires at least c++11.

              My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

              1 Reply Last reply
              3
              • TuniDevT Offline
                TuniDevT Offline
                TuniDev
                wrote on last edited by
                #7

                I find the solution, hope that help some one.

                void Handler_Transaction::saveObject(bool modeThread)
                {
                if(modeThread == true)
                {
                //******************************************************
                // it work for me
                QtConcurrent::run( this{ this->saveObject(false);});
                );
                return;
                }

                //doing script of thread here //
                }

                1 Reply Last reply
                1

                • Login

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