0

I'm currently trying to make a debugging tool which will sit on top of a proprietary application (which interfaces over BLE with hardware).

Inside of this application (written in QT) there is a text box which has the stream of logging information coming from the hardware, and I want to make an application which will monitor that text box and process the data being logged.

I cracked open Spy++ and found the handles of the window I needed, however, it only displayed as "QWidget" and WM_GETTEXT wasn't pulling any data out. These two links also mention that QT widgets can't be read by the standard Win32 API (which feels strange to me, as I was sure everything needed to pass through the Windows GUI layer): https://forum.qt.io/topic/36867/accessing-qtextedit-from-another-program/9 https://forum.qt.io/topic/19256/how-get-handle-of-qwidget-child-with-vb-net/9

I'm open to any and all options! I'm language-agnostic on this one. How can I read out the QTextEdit logging data?

4

2 回答 2

4

Qt 的小部件支持开箱即用的辅助技术(AT)。在 Windows 上,Qt 的辅助功能可通过MSAAIAccessible2获得。任何一个都能够检查小部件树,并跨进程边界传递小部件的属性。

Qt 正式支持任一接口。

于 2015-06-05T09:05:40.510 回答
3

您无法阅读 a 的内容,QTextEdit因为它是一个外星小部件。您可以在QWidget文档中阅读更多内容:

在 Qt 4.4 中引入的外星小部件是窗口系统未知的小部件。它们没有与之关联的本机窗口句柄。此功能显着加快了小部件的绘制、调整大小和消除闪烁。

如果您需要原生窗口的旧行为,您可以选择以下选项之一:

  1. 在您的环境中使用 QT_USE_NATIVE_WINDOWS=1。

  2. 在您的应用程序上设置 Qt::AA_NativeWindows 属性。所有小部件都将是本机小部件。

  3. 在小部件上设置 Qt::WA_NativeWindow 属性:小部件本身及其所有祖先都将变为原生(除非设置了 Qt::WA_DontCreateNativeAncestors)。

  4. 调用 QWidget::winId 来强制一个原生窗口(这意味着 3)。

  5. 设置 Qt::WA_PaintOnScreen 属性以强制使用本机窗口(这意味着 3)。


还有一个可能对您有用的 Qt 内省工具:GammaRay。就个人而言,我没有使用它 - 只阅读了一个小的概述,但它看起来很有希望。

于 2015-06-05T05:58:18.627 回答