开发者

Will I be able to easily port Qt applications?

If I create a Qt binary, then the user that starts it will not need to ha开发者_开发百科ve Qt installed on their computer right? That is, it's like a native support of MFC - it starts everywhere (on Windows, if it was built as exe)? I know libraries should be static/included and so, but I am asking only about Qt compatibility.

Also, if I create a Qt project on Windows, do I need some extra work to use this project on Linux, given the version of Qt is the same? What about Mac?


The Qt libraries will have to be installed on the target machine, unless you statically link the Qt libraries in your executable. (I do not recommend this, the resulting binaries will be huge.)

Depending on the licence you use Qt with, you could also ship the required Qt DLLs with your application.

As for portability, it's very good with Qt. It should compile and run fine as-is on Mac and Linux. (Possible problems are with file paths and such, but there are ways to make that work reliably and portably if you always use the Qt APIs.)


I disagree with Mat -- unless the application was specifically designed and written with portability in mind at all times, you will have to make many changes to get it to compile, to run, and to look good on Linux and Mac. Qt makes this process easier, but it is not entirely painless.


The UI is pretty much bound to look ugly on other systems on the first run. Qt is, first and foremost, a unified UI creation system; meanwhile, in Windows, the menu is a part of the nonclient area of the window, on Mac, it's outside of the window (on screen top instead), and on Linux it's just one of the controls in the client area. Unify that. And don't get me started on the widget diversity on Linux.

So yeah, there will be a nonzero porting effort.


I think there are several separate issues to consider here:

  1. Getting your Qt program to compile under various platforms

  2. Deploying your Qt program on various platforms (so that "normal users" can install and run it without a lot of hassle)

  3. Tweaking your Qt program's look and feel (so that it looks as "native" as possible under the various platforms it to run on)

(1) Is largely a matter of avoiding platform-specific APIs in your program. If you stick to Qt and STL APIs you should be okay. Or if you must use something platform-specific feature, you can do so via #ifdefs for each platform, or by providing separate .cpp files for each platform, but that is a hassle that's best avoided if possible.

(2) Requires slightly different steps for different platforms; There is some documentation about it here.

(3) May or may not be important to you (it depends on how much you care whether your program looks like a native application on each platform). If it is important, then I don't think there is any way around manually trying your program out on each target platform and tweaking it until it looks "just right" for that platform. It helps to design your GUI code to make as few hard-coded assumptions at possible (so that Qt's QStyle layer is free to the 'right thing' based on the current platform).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜