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

来源:互联网 发布:淘宝商品白底素材原图 编辑:程序博客网 时间:2024/06/05 15:47

原文地址::http://stackoverflow.com/questions/3278415/hook-a-qt-application-with-c-to-capture-textname-of-the-application


相关文章

1、Is it possible to use Win32 Hooks in Qt applications----http://stackoverflow.com/questions/2167876/is-it-possible-to-use-win32-hooks-in-qt-applications





3down votefavorite
1

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

shareedit
 

2 Answers

activeoldestvotes
up vote1down vote

I don't know if I completely understand your question, but you could simply use the GetWindowTextfunction (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.

shareedit
 
up vote0down vote

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 windowsand 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().

shareedit

3down votefavorite
1

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

shareedit
 

2 Answers

activeoldestvotes
up vote1down vote

I don't know if I completely understand your question, but you could simply use the GetWindowTextfunction (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.

shareedit
 
up vote0down vote

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 windowsand 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().

shareedit
0 0
原创粉丝点击