Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    Enable GUI for one platform, disable it for others

    General and Desktop
    5
    7
    3197
    Loading More Posts
    • 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
      lordnow last edited by

      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 Reply Quote 0
      • L
        lgeyer last edited by

        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 Reply Quote 0
        • E
          Eddy last edited by

          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 Reply Quote 0
          • L
            lordnow last edited by

            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 Reply Quote 0
            • E
              Eddy last edited by

              Qt Creator of course ;-)

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

              Qt Certified Specialist
              www.edalsolutions.be

              1 Reply Last reply Reply Quote 0
              • G
                giesbert last edited by

                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 Reply Quote 0
                • D
                  dbzhang800 last edited by

                  [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 Reply Quote 0
                  • First post
                    Last post