【问题标题】:Hook a QT Application with C++ to capture textname of the application使用 C++ 挂钩 QT 应用程序以捕获应用程序的文本名称
【发布时间】:2010-07-19 04:14:22
【问题描述】:

我有一个在 Win32 平台上运行的简单 QT 应用程序。我需要编写一个 C++ 程序,描述为:输入是该 QT 应用程序的窗口句柄,它已经可用,输出是应用程序的文本名称(AKA 标题)。我希望有人能告诉我正确的方法。 非常感谢。微笑

【问题讨论】:

    标签: c++ qt winapi hook


    【解决方案1】:

    我不知道我是否完全理解你的问题,但你可以简单地使用GetWindowText 函数 (Windows API 的一部分)获取窗口的标题。当然,您必须将本机窗口句柄 (HWND) 传递给此函数,QWidget::winID() 是 Qt 检索它的方式。

    【讨论】:

      【解决方案2】:

      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.
      

      所以,只需询问您正在使用的 QMainWindow windowTitle()

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-12-07
        • 1970-01-01
        • 2011-05-17
        • 1970-01-01
        相关资源
        最近更新 更多