tags:

views:

345

answers:

3

When you write an application using Qt, it can be run in different operating systems. And - correct me if I'm wrong - you don't need to have Qt already installed in all of the plataforms you execute your application.

How exactly this approach works? Does Qt compiles to the desired platform, does it bundle some "dlls" (libs), how does it do it? Is different from programming a Java application for the sake of cross-platform?

If you use Python to write a Qt application with Python bindings, does the final user needs to have Python installed?

+10  A: 

Qt (ideally) provides source compatibility, not binary compatibility. You still have to compile the application separately for each platform, and use the appropriate dynamic Qt libraries (which also need to be compiled separately, and have some platform-specific code).

For your final question, the user would need Python, the Qt libraries, and the binding library (e.g. pyqt), but there are various ways to bundle these.

Matthew Flaschen
So, without bundling them, I would have a (just an example) a 4mb file to install, and bundling everything something like 40mb - like bundling Java itself if it were Java. Am i right?
Somebody still uses you MS-DOS
Don't know about the exact numbers, but that's basically right. If you know the user already has the right Qt dynamic libraries, you don't have to bundle them.
Matthew Flaschen
+5  A: 

The problem is your definition of "installed". For Qt to work, the executable just has to have access to the proper libraries.

Of course that for each platform a different executable and libraries have to be produced (see Qt docs).

About Python, if you are to run a Python executable you have to have it installed (in a more traditional kind of way). Unless you are running with py2exe in Windows, for instance.

Vinko Vrsalovic
So, does Qt handles everything for me for these libraries, for each plataform I deploy an application? I create a cross-plataform one, and want to deploy it on Linux and Windows, does it bundle these libs in a a transparent way?
Somebody still uses you MS-DOS
No, Qt just provides a means to generate from the same source, different binaries that will run in different platforms. You'd still have to provide different binaries/installers for each platform. You could have a single installer to detect platform and install the proper version, but I fail to see any benefit to that approach.
Vinko Vrsalovic
My bad, I know it's going to create different binaries. I just want to know if Qt creates them for me.
Somebody still uses you MS-DOS
@Somebody still uses you MS-DOS - Qt doesn't create the other binaries for you (although it does come with a multi-platform replacement for make) it simply has a set of function calls to do all the platform specific stuff (like gui/filesystem) that are the same on all platforms. Then you simply bundle the Qt libraries for the platform you are targetting,
Martin Beckett
+5  A: 

PyQT is a great cross-platform QT binding for python, but it is not a magic solution for shipping your application for all platforms without doing any packaging/installer maintenance. I think maybe you might be expecting some magic.

It is a cross-platform library. That means, you can write your C++ or Python (or other language with bindings) code once, and create a "window" (a form, a dialog box, something on the screen) and populate it with controls (buttons, and all that) and not have to deal with the platform differences in how buttons are made in Windows, Linux, and on Mac OS X.

Because it is a library, it can be packaged in multiple ways. It can be "statically linked" (built into your executable/binary/app) or "dynamically linked" (known as a DLL in windows, a shared library or on unix/linux or as a framework, in mac os x). It is not always "installed" on a computer, unless it is a shared library.

Even when it is "installed" onto a computer, multiple versions might exist on that computer, and so it is not proper to think of it as being an extension to your computer, but rather an extension to an application (a program) on your computer.

If you use Python bindings for QT, then your installation package for your application needs to include the QT binding's binary files (python extensions), the basic Python runtime environment including the Python executable and basic libraries, and your program's source code. It is possible to package most of this up into a single "bundle". On Mac OS X, for instance, all this can easily be put into a an ".app" bundle, and on Windows, and Linux, I believe there are packaging and installation tools that can help you do this easily.

Even though you will only need to write the user interface code for your application once, you will not magically get the ability to ship an application on all three primary platforms at once, without doing at least the building of the installer or packaging, separately for each platform. Users expect to download a setup/install package for Windows or Mac OS X, and perhaps for Unix/Linux it depends further on which distribution you install.

Update thanks to AdamW for this nokia link providing deployment information

Warren P
Warren, thanks for a clarifying answer in so many levels. I'm asking this question because I was thinking of a Python app, and thought about going cross-platform, but I'm new to Desktop programming (I develop mainly web). I came with GTK, Qt and Appcelerator and I was trying to really understand which of these solutions would be ideal for me based in what they exatcly offer.
Somebody still uses you MS-DOS
Python gives you a huge benefit in language (easy to learn, and powerful) but one area of Python that is hugely fragmented is the "Which GUI?" question. You should probably consider Python Bindings for WxWidgets as well. Some people say that if the TkInter (tcl/tk) gui (which I think is crap) hadn't shipped first, that WxPython would have been the default Python GUI. It also handles Windows, Mac, and Linux, and has a large active community.
Warren P
@Somebody if you're looking for a markup file that is cross-platform language-agnostic like HTML/CSS for QT be sure to check out QML.
Evan Plaice
Is QML the XAML equivalent for QT?
Warren P