What are Qt widget components doing in the background?
-
Hi and welcome to devnet,
What exactly do you want to know ?
Qt widgets go through nothing. They are C++ classes. There's no transformation.
-
Qt widgets are adapters/wrappers to the native widgets to provide a cross platform way of handling this. For Linux and embedded systems they also provide their own implementation. These also come in handy when using stylesheets. Mouse event and keyboard events and other OS events get translated to Qt events. So, basically you have different backends for different operating systems. This selection is done when compiling Qt for a specific platform. There are only very few features that are specific to only one operating system. Basically, in these cases you could just switch over to native programming. The compiler does not matter as it is related to Qt. On Windows MSVC and MinGW are not compatible, but this is not a problem inherent to Qt.
Unless anything that Microsoft does, Qt's main goal is cross platform portability. If you just want to write an app for Windows and are sure that never ever will you port it to a different operating system you don't have to use Qt. You can just go directly with anything Microsoft provides. One reason to still consider Qt is that it is stable whereas Microsoft reinvents a better GUI framework that you should use now every couple of years. Qt abstracts that away for you.
-
@SGaist said in What are Qt widget components doing in the background?:
If you want the gory details, take a look at Qt's code source, it will be easier to get the grip at what is happening.
I reviewed it but I don't fully understand it. I didn't have an answer in my head
-
@SGaist How do we write a code so that the object we created as a qpushbutton can exist as a button on the screen?
what is the most basic need for this? are there different processes for windows and different processes for linux?I'm so sorry if my explanations or questions are complicated
-
@elifsz
You either create aQPushbutton
and directly callshow()
on it, which would be unlikely as it would give you a window which consisted of nothing but a pushbutton, or you add it onto some other qtQWidget
and show that.Whatever you question/thought about "What are Qt widget components doing in the background?" is, forget about it :) You are worrying about something unnecessary.
-
@elifsz sure things are different between Windows and Linux. If not, there would be no need for Qt.
As for your issue, you just build your interface using Qt's elements. The rest is done between the QStyle dedicated to the platform and the QPA backend.
You seem to be a bit over-thinking that part currently. Or are you looking to adapt Qt to a new platform ?
-
@SGaist The reason I asked this question was because my manager, who did not write qt, said why there is qt, it already takes microsoft components directly.
There is no such situation that I know of, but I could not explain myself.I wanted to ask because my research did not yield any final results.
-
At the beginning of times, creating a GUI, be it on Windows or Linux, was something that wasn't easy to learn nor do and was not reusable at all. Qt was created to make the life of developers way easier as well as provide a framework that allows you to write your code once and then build it on a per platform basis. If you want another example, try to show an OpenGL window using native APIs vs doing with Qt.
Qt is:
- simplicity
- elegance
- cross platform