Wtx ~ Wt Extension Library
WtxLib
Rutin to log the actual widget tree

Reprinted with permission: https://redmine.emweb.be/boards/1/topics/14570

Added by Tibor Peak

I just share these routines that I use for debugging purposes:

The first is to show the widget variable name on the GUI when mouse pointer is hold over a widget:

#define DebugTooltip(vName) vName->setAttributeValue("title",#vName)
void myApplication::AddWidgetStructureDebugTitles(){
DebugTooltip(firstLine_CW);
DebugTooltip(secondLine_CW);
DebugTooltip(siaLogo_Img);
// .......
DebugTooltip(Feedback_OMF);
}

The second routine logs the widget tree structure (starting with the widget received as a parameter), using the title attributes set by the previous routine:

void myApplication::ListWidgets(WWebWidget *startPoint, long Counter){
WWebWidget *thisWebWidget;
WTabWidget *thisTabWidget;
std::string thisTypeName;
std::string thisMessage;
std::string spaces(" "); // 48 space chars
char Buf[17];
std::vector< WWidget * > WidgetList;
WidgetList = startPoint->children();
for (vector<WWidget *>::iterator it = WidgetList.begin(); it != WidgetList.end(); ++it) {
thisWebWidget = (WWebWidget *)*it;
thisTypeName = typeid(*thisWebWidget).name();
sprintf(Buf,"%02ld",Counter);
thisMessage = Buf + (string)". " + spaces.substr(0, (Counter - 1) * 2) + thisTypeName;
thisMessage = thisMessage + spaces.substr(0, max(1, (40 - thisMessage.length())));
if (thisTypeName == "class Wt::WTabWidget") {
thisTabWidget = (WTabWidget *)*it;
wApp->log("Info:") << thisMessage << " / " << thisTabWidget->attributeValue("title");
short tabCount = thisTabWidget->count();
for (short i = 0; i < tabCount; i++) {
thisWebWidget = (WWebWidget *)(thisTabWidget->widget(i));
thisTypeName = typeid(*thisWebWidget).name();
thisMessage = Buf + (string)". " + spaces.substr(0, (Counter - 1) * 2) + thisTypeName;
thisMessage = thisMessage + spaces.substr(0, max(1, (40 - thisMessage.length())));
wApp->log("Info:") << thisMessage << " / " << thisWebWidget->attributeValue("title");
if (thisWebWidget->children().size() > 0) {
ListWidgets(thisWebWidget, Counter + 1);
}
}
} else {
wApp->log("Info:") << thisMessage << " / " << thisWebWidget->attributeValue("title");
if (thisWebWidget->children().size() > 0) {
ListWidgets(thisWebWidget, Counter + 1);
}
}
}
}

Feel free to use it.