BibleTime
debugwindow.cpp
Go to the documentation of this file.
1/*********
2*
3* In the name of the Father, and of the Son, and of the Holy Spirit.
4*
5* This file is part of BibleTime's source code, https://bibletime.info/
6*
7* Copyright 1999-2025 by the BibleTime developers.
8* The BibleTime source code is licensed under the GNU General Public License
9* version 2.0.
10*
11**********/
12
13#include "debugwindow.h"
14
15#include <QApplication>
16
17
19 : QTextEdit(nullptr)
20 , m_updateTimerId(startTimer(100))
21{
22 setWindowFlags(Qt::Dialog);
23 setAttribute(Qt::WA_DeleteOnClose);
24 setReadOnly(true);
26 show();
27}
28
30{ setWindowTitle(tr("What's this widget?")); }
31
32void DebugWindow::timerEvent(QTimerEvent * const event) {
33 if (event->timerId() == m_updateTimerId) {
34 if (QObject const * w = QApplication::widgetAt(QCursor::pos())) {
35 QString objectHierarchy;
36 do {
37 QMetaObject const * m = w->metaObject();
38 QString classHierarchy;
39 do {
40 if (!classHierarchy.isEmpty())
41 classHierarchy += QStringLiteral(": ");
42 classHierarchy += m->className();
43 m = m->superClass();
44 } while (m);
45 if (!objectHierarchy.isEmpty()) {
46 objectHierarchy
47 .append(QStringLiteral("<br/>"))
48 .append(tr("<b>child of:</b> %1").arg(
49 classHierarchy));
50 } else {
51 objectHierarchy.append(
52 tr("<b>This widget is:</b> %1").arg(
53 classHierarchy));
54 }
55 w = w->parent();
56 } while (w);
57 setHtml(objectHierarchy);
58 } else {
59 setText(tr("No widget"));
60 }
61 } else {
62 QTextEdit::timerEvent(event);
63 }
64}
65
void timerEvent(QTimerEvent *const event) override
int const m_updateTimerId
Definition debugwindow.h:32
void retranslateUi()