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. Compilation error - 'QFuture' is not declared in this scope - Qt

Compilation error - 'QFuture' is not declared in this scope - Qt

Scheduled Pinned Locked Moved Mobile and Embedded
9 Posts 3 Posters 4.1k 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.
  • R Offline
    R Offline
    raj.qtdev
    wrote on last edited by
    #1

    Hello there,

    I am trying to use QFuture and QtConcurrent classes in my application. I # included <QFuture> like this:

    <QtCore/QFuture>

    but when i compiled, got a compilation error. I could not event # include QtConcurrent.

    Do I need to include something else in my .pro file to use both of these?

    thanks

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      It should work. Did you use some special custom configure flags (if you have compiled Qt yourself)?

      (Z(:^

      1 Reply Last reply
      0
      • R Offline
        R Offline
        raj.qtdev
        wrote on last edited by
        #3

        No nothing of that sort. Yeah, its strange. I am using Qt version 4.7.3 on QtCreator.

        I just want to try something like

        @void myclass::fun()
        {}

        void myclass::init()
        {
        QFuture<void> future = QtConcurrent::run(fun);
        future.waitForFinished();
        }@

        therefore i want to include QFuture which documentation says should be found in @QtCore@ . Even after including QFuture, I am getting compilation error. QtConcurrent is not even getting included.

        Please let me know if there is some issue with this.

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          I've never used that class. Here is what stackoverflow has to say on this: "link":http://stackoverflow.com/questions/16150961/qfuture-help-threading-c-qt.

          So:
          @
          #include <QFuture>
          #include <QtConcurrent/QtConcurrentRun>
          @

          (Z(:^

          1 Reply Last reply
          0
          • R Offline
            R Offline
            raj.qtdev
            wrote on last edited by
            #5

            Thanks for putting a search but doesn't work for me. Can you please try creating a hello world app and use these?

            1 Reply Last reply
            0
            • C Offline
              C Offline
              cincirin
              wrote on last edited by
              #6

              [quote author="raj.qtdev" date="1382959691"]Thanks for putting a search but doesn't work for me. [/quote]

              What exactly didn't work for you ? The compiler don't find the QFuture header or other linker error ? What sierdzio said is correct, so you should be fine including QFuture in that way. From what I see you try to run a class member function, in this case you need something like this:
              @
              QFuture<void> future = QtConcurrent::run(this, &myclass::run)
              @

              1 Reply Last reply
              0
              • R Offline
                R Offline
                raj.qtdev
                wrote on last edited by
                #7

                That is okay @cincirin. The compiler didn't find the QFuture header and the QtConcurrent header that is the main issue. Should be simple thing but don't know what is missing apart from #including the two headers

                1 Reply Last reply
                0
                • sierdzioS Offline
                  sierdzioS Offline
                  sierdzio
                  Moderators
                  wrote on last edited by
                  #8

                  Perhaps you forgot to include this in your .pro file, but that is unlikely:
                  @
                  QT += core
                  @

                  Since you have posted it in Mobile and Embedded, let me ask you this: even though you have not compiled Qt yourself, maybe you are aware of some special conditions your platform may be forcing? Maybe threading support is somehow throttled on that hardware?

                  (Z(:^

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    cincirin
                    wrote on last edited by
                    #9

                    Ok, I simply included the two files in this way:
                    @
                    #include <QFuture>
                    #include <QtConcurrentRun>
                    @

                    The project is successfully compiled even with Qt 4.5.3 on both Mac and Windows.

                    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