Congratulations to our 2022 Qt Champions!

Can't use C++ property in QML if using preprocessor condition

  • Hi everyone!

    I have a question how I can enable/disable proper in my class for one platform. In my case I need hide a few properties for desktop OS and show this properties for mobile OS. I use this code to check:

        #if defined(Q_OS_IOS)
                Q_PROPERTY(RedmineMobileHelper* mobile READ getMobile)
        #if defined(Q_OS_IOS)
                inline RedmineMobileHelper* getMobile(){return m_mobile;}

    When I build my plugin for iOS this code works for C++. But in QML project where I'm using plugin I can't get property value (it's always receive 'undefined').

    What I do wrong?

  • Lifetime Qt Champion


    I might be wrong but I wonder if you're not entering a corner case here. I'd recommend posting this to the interest mailing list. You'l find there Qt's developers/maintainers (this forum is more user oriented)