简体   繁体   中英

Hook a QT Application with C++ to capture textname of the application

I have a simple QT application running on Win32 platform. I need to write a C++ program described as: the input is the windows handle of that QT application, which is already available, the output is the text name ( AKA caption ) of the application. I hope someone will show me the way to do this right. Thanks a lot. Smile

I don't know if I completely understand your question, but you could simply use the GetWindowText function (part of the Windows API) to obtain the title of a window. You must of course pass a native window handle ( HWND ) to this function, QWidget::winID() is the Qt way to retrieve it.

http://doc.trolltech.com/4.6/qwidget.html#windowTitle-prop

This property holds the window title (caption).

This property only makes sense for top-level widgets, such as windows
and dialogs. If no caption has been set, the title is based of the 
windowFilePath. If neither of these is set, then the title is an empty string.

so, just ask the QMainWindow you are using about the windowTitle() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM