Introspects a QWidget tree and dumps named, scriptable widgets for debugging and documentation.
WidgetDumper walks a widget hierarchy starting from a given root, identifying widgets that have an explicit objectName() set. Widgets are classified as "interactive" (e.g. QPushButton, QComboBox, QLineEdit - see the interactive type list in the .cpp) or "structural" (containers and other named widgets that aren't directly interactive), and can optionally include their current combo/list items.
Widgets whose objectName() starts with "qt_" (Qt's own internal/private widgets) are skipped but still traversed into, so their named children are still discovered.
Output can be produced in three forms:
- logWidgets(): a one-shot dump to qDebug().
- beginWidgetDumpHtml()/dumpWidgetsHtml()/endWidgetDumpHtml(): an interactive, collapsible HTML report accumulated across multiple sections/contexts, written to disk.
- beginWidgetDumpJson()/dumpWidgetsJson()/endWidgetDumpJson(): a structured JSON dump of interactive widgets only, suitable for automated snapshot comparison in tests.
All public methods are exposed to VQScript via Q_INVOKABLE.
|
| void | logWidgets (QWidget *root, string context=string(), bool showInteractive=true, bool showNonInteractive=true) |
| | Dumps the named widgets under root to qDebug() as a single, indented one-shot report.
|
| void | beginWidgetDumpHtml (string filePath) |
| | Starts a new HTML widget-dump session, creating (or overwriting) the report file.
|
| void | dumpWidgetsHtml (QWidget *root, string context=string(), bool showInteractive=true, bool showNonInteractive=true) |
| | Appends one widget-tree section to the current HTML dump session.
|
| void | endWidgetDumpHtml () |
| | Closes out the current HTML dump session, writing the closing document tags to disk.
|
| void | beginWidgetDumpJson (string filePath) |
| | Starts a new JSON widget-dump session, resetting any previously accumulated sections.
|
| void | dumpWidgetsJson (QWidget *root, string context=string()) |
| | Appends one widget-tree section to the current JSON dump session.
|
| void | endWidgetDumpJson () |
| | Closes out the current JSON dump session, writing all accumulated sections to disk.
|
| void dumpWidgetsHtml |
( |
QWidget * | root, |
|
|
string | context = string(), |
|
|
bool | showInteractive = true, |
|
|
bool | showNonInteractive = true ) |
|
slot |
Appends one widget-tree section to the current HTML dump session.
Each call adds a collapsible <section> - with an optional heading derived from context - containing the named widgets under root, rendered as nested <details>/<div> elements. Combo box items, if any, are listed under their widget. Requires an active session started with beginWidgetDumpHtml().
- Parameters
-
| root | The widget subtree to traverse. If null, a warning is logged and nothing is written. |
| context | Optional section label, used as both the visible heading and its anchor id. |
| showInteractive | If true, include interactive widgets in this section. |
| showNonInteractive | If true, include structural/non-interactive named widgets in this section. |