Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Is there a general Qt #define that can be checked for?

Is there a general Qt #define that can be checked for?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.0k 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.
  • E Offline
    E Offline
    Eonz
    wrote on last edited by
    #1

    I have some code files that I would like to share between different platforms (some of which are not supported by Qt). I want to be able to check if it the file is being compiled in a Qt environment and then use some Qt features. Is there a #define that can be checked for presence of the Qt framework to achieve this?

    Hypothetical example:

    @
    #ifdef QT_FRAMEWORK_AVAILABLE

    #include <QApplication>

    double randomInRange(double min, double max)
    {
    return min + (max - min) * ((double)qrand() / (RAND_MAX + 1));
    }

    #elseif

    double randomInRange(double min, double max)
    {
    return min + (max - min) * ((double)rand() / (RAND_MAX + 1));
    }

    #endif
    @

    1 Reply Last reply
    0
    • B Offline
      B Offline
      butterface
      wrote on last edited by
      #2

      You can use QT_VERSION for example or in the case written above also QT_CORE_LIB might be possible.

      1 Reply Last reply
      0
      • E Offline
        E Offline
        Eonz
        wrote on last edited by
        #3

        Thanks for this.

        QT_CORE_LIB should probably be sufficient for all the cases I will ever encounter.

        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