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. MOC and Q_OS_XXX defines

MOC and Q_OS_XXX defines

Scheduled Pinned Locked Moved Mobile and Embedded
3 Posts 2 Posters 863 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.
  • G Offline
    G Offline
    gardiol
    wrote on last edited by gardiol
    #1

    Hi!
    i am tyring to create a few alternative classes for different platforms and it seems that the moc compiler does not understand any Q_OS_XXX defines. For example the code:

    class Device: public QObject
    {    
         Q_OBJECT
    ... blah ...
    public slots:
    #ifdef Q_OS_ANDROID
           void mySlot()
    #end if
    

    The mySlot() is not recognized at runtime and connect that slot result in a runtime error...

    How should i create a platform-dependent slot?

    1 Reply Last reply
    0
    • H Offline
      H Offline
      Huulivoide
      wrote on last edited by
      #2

      Create a parent class with the common code and a platform
      dependent child class for each platform or just don't use
      the platform depended slots in platforms that don't support them.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        gardiol
        wrote on last edited by
        #3

        Yes this was already the case.
        I was just trying to avoid compilation of the child class on the wrong platform...

        I solved it by moving the SOURCES and INCLUDES in the "pro" file from the global section to a per-platform specific.

        Before:

         SOURCES = android-only-class.cpp
         INCLUDES = android-only.headers.h
        

        After:

        unix:android {
         SOURCES += android-only-class.cpp
         INCLUDES += android-only.headers.h
        }
        

        By the way, the "unix:android" seems to be undocumented, but it works.

        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