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. Enable GUI for one platform, disable it for others

Enable GUI for one platform, disable it for others

Scheduled Pinned Locked Moved General and Desktop
7 Posts 5 Posters 3.7k 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.
  • L Offline
    L Offline
    lordnow
    wrote on last edited by
    #1

    Hello,
    I am beginning a project that needs to run on both Windows and Unix machines. This project will parse a xml file as input and carry out a few simple tasks that will inquire access to sockets, environmental variables etc.

    The problem is that I need to use GUI for the Windows machines and not use it on the Unix machines (since they don't have a graphical interface at all).

    My goal is to make a single project that would be statically compiled for each platform rather than creating 2 separate projects.

    I was wondering if Qt is the right framework for me. Is it possible to not use the GUI and replace it with printouts to STDOUT using #ifndef WIN32 or something of that nature?

    Thank you.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      See "QtGlobal":http://doc.qt.nokia.com/latest/qtglobal.html#Q_OS_AIX.

      @
      int main(int argc, char* argv[])
      {
      #ifdef Q_OS_WIN32
      QApplication application(argc, argv);

      // ... (GUI related stuff)
      

      #else
      QCoreApplication application(argc, argv);

      // ... (CLI related stuff)
      

      #endif

      return application.exec();
      

      }
      @

      1 Reply Last reply
      0
      • EddyE Offline
        EddyE Offline
        Eddy
        wrote on last edited by
        #3

        Yes, it is possible to use blocks of code only when the requirements are valuable like you want.

        If you use Qt Creator those "not needed" blocks of code will have a grey background helping you to see which code is not active in your project.

        Qt Certified Specialist
        www.edalsolutions.be

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lordnow
          wrote on last edited by
          #4

          Excellent.
          Now all I need to know is which IDE to choose.
          My default choice is to use Visual Studio 2008 with the Qt plugin.
          However, I don't know if I would be able to compile the code for use on Unix system.

          Does the Qt plugin bring it's own compiler or uses the one of VS?

          Which IDE do you recommend for this project?

          Thank you.

          1 Reply Last reply
          0
          • EddyE Offline
            EddyE Offline
            Eddy
            wrote on last edited by
            #5

            Qt Creator of course ;-)

            Edit: you can choose your compiler : nmake, cmake, mingw-make, ...

            Qt Certified Specialist
            www.edalsolutions.be

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #6

              You have to compile for each platform seperately.

              I suggest using QtCReator as it uses Qt projects files to buikld and is available for those platforms. But with MSVS you can't cross compile for Unix from windows. MSVS plugin just adds siome features not a compiler to MSVS.

              If you create your project with Creator, you have a purs Qt project based on qmake, which can also be used on Unix with installed Qt.

              The you can choose to use mingw or msvs for windows and gcc on linux for example.

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • D Offline
                D Offline
                dbzhang800
                wrote on last edited by
                #7

                [quote author="lord$now" date="1310807244"]
                Does the Qt plugin bring it's own compiler or uses the one of VS?

                Which IDE do you recommend for this project?
                [/quote]

                Yeah, VS using its own compiler whether or not you using Qt plugin.

                If you are looking for an crossplatform IDE, you can choose QtCreator or eclipse.

                However, you can use Visual Studio under windows, and use another IDE under other platform.

                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