VivoQuant 6.4.0
Loading...
Searching...
No Matches
WidgetDumper Class Reference

Description

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.

Public Slots

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.

Public Member Functions

 WidgetDumper (QObject *parent=nullptr)
 Constructs a WidgetDumper.

Constructor & Destructor Documentation

◆ WidgetDumper()

WidgetDumper ( QObject * parent = nullptr)
explicit

Constructs a WidgetDumper.

Parameters
parentOptional QObject parent.

Member Function Documentation

◆ beginWidgetDumpHtml

void beginWidgetDumpHtml ( string filePath)
slot

Starts a new HTML widget-dump session, creating (or overwriting) the report file.

Must be called before any dumpWidgetsHtml() calls. Writes the HTML document header/styles to disk. Pair with a matching endWidgetDumpHtml() call to close the file.

Parameters
filePathPath to the HTML file to create.

◆ beginWidgetDumpJson

void beginWidgetDumpJson ( string filePath)
slot

Starts a new JSON widget-dump session, resetting any previously accumulated sections.

Must be called before any dumpWidgetsJson() calls. The file itself is not written until endWidgetDumpJson() is called.

Parameters
filePathPath to the JSON file that will be written on endWidgetDumpJson().

◆ dumpWidgetsHtml

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
rootThe widget subtree to traverse. If null, a warning is logged and nothing is written.
contextOptional section label, used as both the visible heading and its anchor id.
showInteractiveIf true, include interactive widgets in this section.
showNonInteractiveIf true, include structural/non-interactive named widgets in this section.

◆ dumpWidgetsJson

void dumpWidgetsJson ( QWidget * root,
string context = string() )
slot

Appends one widget-tree section to the current JSON dump session.

Only interactive widgets are included. Each widget entry records its objectName(), class name, and - for combo boxes with items - an "items" array of its current entries. Requires an active session started with beginWidgetDumpJson().

Parameters
rootThe widget subtree to traverse. If null, a warning is logged and nothing is added.
contextSection label stored alongside this section's widgets (used e.g. as a lookup key when comparing dumps against a reference snapshot).

◆ endWidgetDumpHtml

void endWidgetDumpHtml ( )
slot

Closes out the current HTML dump session, writing the closing document tags to disk.

Must be called after all dumpWidgetsHtml() calls for a session to produce a well-formed HTML file.

◆ endWidgetDumpJson

void endWidgetDumpJson ( )
slot

Closes out the current JSON dump session, writing all accumulated sections to disk.

The output document includes the current release version (see MyGlobals::getReleaseVersion()) alongside the "sections" array built up via dumpWidgetsJson() calls.

◆ logWidgets

void logWidgets ( QWidget * root,
string context = string(),
bool showInteractive = true,
bool showNonInteractive = true )
slot

Dumps the named widgets under root to qDebug() as a single, indented one-shot report.

Depth in the widget tree is reflected as indentation. Each entry shows the widget's objectName(), class name, and - if present - its tooltip and (for combo boxes) its current items.

Parameters
rootThe widget subtree to traverse. If null, a warning is logged and nothing is dumped.
contextOptional label identifying this dump (e.g. a dialog or panel name), printed in the header line.
showInteractiveIf true, include interactive widgets (buttons, combo boxes, edits, etc.) in the output.
showNonInteractiveIf true, include structural/non-interactive named widgets in the output.