What winapi functions does QT use to display text? [closed]
I'm interested in WinApi functions that QT uses to display text (on buttons, etc.)
Any input will be appreaciated.
Edit: I'm interested in the particular functions which are used, that is, their names. Let's say we have a QLabel with text set, now, what gdi/user32 function will be called in the end to get the text out.
The reason why Spy++ doesn't see any child windows is because the windows you're seeing is actually one big window and Qt draws in the buttons. So these buttons you see don't have their own HWND
s. Qt happens to also implement some kind of event system so that when you "click" on a "button" it does something. They are what we call "lightweight" controls or "windowless" controls.
It's the same way Internet Explorer and Firefox works. The buttons you see on a webpage are drawn by the rendering engine and the browser simulates button clicks.
For this reason looking at how Qt works is actually a pretty bad way to learn how the Windows API works. The code that interfaces with the Windows API is buried deep in the source. Qt is a cross-platform framework, so it can't expose the Windows API in the public interface.
If you want to start out with the Windows API, you can start with this tutorial. It'll show how you can create windows, buttons etc. with nothing but C++ and the Windows API in a step-by-step fashion.
Note that the Windows API is not a GUI toolkit (even though everyone seems to think it is). It's low-level application interface to the operating system itself, providing the primitives needed (e.g. files, windows, threads, networking, etc.) to implement your application programs. That's why you'll see many people use a framework or a library (like Qt, FLTK, WxWidgets, etc.) or write up their own.
Qt does use CreateWindowEx
only when it creates Top level windows, or any REAL Windows (e.g. Qt::Window
or Qt::Tool
flag set).
The rest is emulated. Qt is taking the bitmaps from UxTheme on Windows and uses it's own routines for everything - events, messages, event loop, rendering.
These magics that you see - Native windows with 3d Effects.... They are actually non native, they only LOOK native. They are UxTheme's bitmaps converted to OpenGL Textures (or Direct3D Textures) and rendered with the GPU.
It appeared that Qt CALLS TextOut
sometime, but not always. For example, own font rendering occurs in QGLWidgets or if GraphicsEffect is set.
So your answer is: go check in the source. The way QT renders everything is interesting, but not relying on API functions like GDI TextOut.
It will be extremely difficult to hook into Qt apps with the Windows' way.
精彩评论