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. #define to distinguish between widget and console app
Forum Updated to NodeBB v4.3 + New Features

#define to distinguish between widget and console app

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 302 Views
  • 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.
  • M Offline
    M Offline
    MECoder
    wrote on 28 Mar 2023, 10:33 last edited by
    #1

    Hi,
    i have some classes that i wan to use in both applications (widget and console),
    but i need to deactivate some code parts like this:

    #ifdef WIDGET_APP
    code for WIDGET_APP
    #else
    code for CONSOLE_APP
    #endif

    Does Qt provide such a define? Didn't found anything in QtGlobal or how can this be done?

    J 1 Reply Last reply 28 Mar 2023, 10:48
    0
    • M MECoder
      28 Mar 2023, 10:33

      Hi,
      i have some classes that i wan to use in both applications (widget and console),
      but i need to deactivate some code parts like this:

      #ifdef WIDGET_APP
      code for WIDGET_APP
      #else
      code for CONSOLE_APP
      #endif

      Does Qt provide such a define? Didn't found anything in QtGlobal or how can this be done?

      J Offline
      J Offline
      JonB
      wrote on 28 Mar 2023, 10:48 last edited by
      #2

      @MECoder
      If you are using qmake/.pro file and it has QT += widgets in it then see if QT_WIDGETS_LIB is defined? If you have QT += gui, then see if QT_GUI_LIB is defined? I am not sure about these.

      M 1 Reply Last reply 28 Mar 2023, 10:54
      0
      • J JonB
        28 Mar 2023, 10:48

        @MECoder
        If you are using qmake/.pro file and it has QT += widgets in it then see if QT_WIDGETS_LIB is defined? If you have QT += gui, then see if QT_GUI_LIB is defined? I am not sure about these.

        M Offline
        M Offline
        MECoder
        wrote on 28 Mar 2023, 10:54 last edited by
        #3

        @JonB said in #define to distinguish between widget and console app:

        If you are using qmake/.pro file and it has QT += widgets in it then see if QT_WIDGETS_LIB is defined? If you have QT += gui, then see if QT_GUI_LIB is defined? I am not sure about these.

        Thx JonB, that's what i needed.

        1 Reply Last reply
        0
        • M MECoder has marked this topic as solved on 28 Mar 2023, 10:54

        1/3

        28 Mar 2023, 10:33

        • Login

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