Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the advantage of using the native C++ Qt over PyQt [closed]

Tags:

c++

python

qt

qt4

pyqt

I want to develop in Qt, and I already know Python. I am learning C++, so what are the advantages of programming Qt in C++ over Python? C++ seems more complicated, and seems like there is not much gain.

like image 468
Orcris Avatar asked Apr 12 '12 21:04

Orcris


People also ask

What is the difference between Qt and PyQt?

You can choose between two libraries for using Qt from Python: PyQt is mature but requires you to purchase a license for commercial projects. Qt for Python is a recent push by Qt the company to officially support Python. It's offered under the LGPL and can thus often be used for free.

Should I use PySide or PyQt?

Advantages of PySide PySide represents the official set of Python bindings backed up by the Qt Company. PySide comes with a license under the LGPL, meaning it is simpler to incorporate into commercial projects when compared with PyQt. It allows the programmer to use QtQuick or QML to establish the user interface.

Which is better PyQt or wxPython?

Which is better? Depends. The wxPython is simple to use and solutions can be easily created when it is not simple. However, the PyQt is big and has a lot of convenience that comes with this size.

What is the difference between PyQt5 and Qt Designer?

PyQt is built off of the C++ Qt library which is used for developing GUIs for a variety of multi-platform applications. PyQt widgets can be created in various ways depending on the level of customization required. Qt Designer is a Qt tool used for designing and building GUIs using a what-you-see-is-what-you-get-editor.


1 Answers

What is the advantage of using the native C++ Qt over PyQt

Speed/power/control.

PyQt application will still require python. C++/Qt Application compiles to native exe. By using C++ you'll get access to 3rd party libraries that won't be available in python, plus you'll exterminate "middle man" - layer that sits between your program and qt dlls and potentially you can get better performance. For example, I would not write an archiver or mp3 decompressor in python, although it certainly can be done.

However that comes at a cost - c++ does not have a garbage collector, is much more complex, has "slower" development (compilation time), requires years to master and you'll get better performance only if your bottleneck is in within interpreter (i.e. scripted language overhead). I.e. C++ gives more power at a cost of greater responsibility and longer development time. If you don't need that, then you don't have a reason to stick with C++.

Choice of language depends on your application/situation and your personal preferences. If you need to make application SOON or make a mockup, then it'll be reasonable to use language you're familiar with. If you have serious performance problems, then it'll be reasonable to hire skilled C++ programmer to do the job - make native application, profile it, optimize, etc.

Please note that language is a tool. If you want to use your language for everything simply because you like the language, you're not working efficiently.

--EDIT--

Personally, I would not use python for a larger application I'm expected to maintain for a long time. However, this is because the language is not exactly compatible with my mindset (reliance on Murphy's Law) and (as a result) I'm not comfortable with it. Person that thinks differently will be probably much more comfortable with Python and might even think that C++ is too restrictive.

Another thing is that judging from my experience of writing Blender plugins and various python scripts, there's some serious performance overheads that appears because language is scripted, and very heavy list/map/array manipulation that can be performed FAST for free in C++ might take 5x..10x times longer in python. Some people might insist that this can be fixed, however, cost of this "fixing" might overcome benefits you get from using scripted language. Regardless of my preference, I still use Python for making utility scripts that need to run several utilities, split/splice/parse their text output and do something with it (C++ isn't very good at this situations), and I'd still provide Python bindings (assuming Lua is no good) in a program that must be extensible.

In the end it comes down to selection of most suitable tool - if C++ will not give you any benefit compared to Python, then there's no reason to switch.

like image 100
SigTerm Avatar answered Oct 06 '22 01:10

SigTerm