开发者

What winapi functions does QT use to display text? [closed]

开发者 https://www.devze.com 2023-02-28 13:18 出处:网络
It's difficult to tel开发者_StackOverflow社区l what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its curr
It's difficult to tel开发者_StackOverflow社区l what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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 HWNDs. 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.

0

精彩评论

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