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] Exclude androidextras from desktop builds
Qt 6.11 is out! See what's new in the release blog

[solved] Exclude androidextras from desktop builds

Scheduled Pinned Locked Moved Mobile and Embedded
6 Posts 3 Posters 2.4k 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
    habamax
    wrote on last edited by
    #1

    I have an android application which includes androidextras.
    To build it for desktop I have to manually remove all androidextras stuff.

    How can I #ifdef that?

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      Include this in your .pro file
      @
      android {
      QT += androidextras
      }
      @

      and then in cpp,
      @
      #ifdef Q_OS_ANDROID
      #endif
      @

      157

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

        Hi,

        To add to p3c0, if your android specific code has a certain size, you can also keep the implementation in their own source file and only include them in the android scope

        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
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          Yes SGaist that's a good point.
          This evaluates to something like this for e.g:
          @
          android {
          SOURCES += androidintent.cpp
          }

          and

          android {
          HEADERS += androidintent.h
          }
          @

          157

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

            Thx!

            What about QML part? If I exclude all android sources I have to do something to QML too.

            I have exposed context object to QML which is based on androidextras. And there on event I call its method.

            I thought of #ifdef'ing contents of those exposed methods so they would do nothing if build not against android.

            Does it make sense?

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

              You could have a base object that does nothing and a derived class for android where you will do the stuff you need. So in QML you don't have to change the code.

              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

              • Login

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