Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qqmldebugconsole_p.h
Go to the documentation of this file.
1
// Copyright (C) 2026 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant
4
5
#
ifndef
QQMLDEBUGCONSOLE_P_H
6
#
define
QQMLDEBUGCONSOLE_P_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtCore
/
qobject
.
h
>
20
#
include
<
QtCore
/
qstringlist
.
h
>
21
#
include
<
QtCore
/
qthread
.
h
>
22
23
#
include
<
functional
>
24
25
QT_BEGIN_NAMESPACE
26
27
class
QQmlDebugCommandListener;
28
29
// A simple interactive command line for QML debugging tools. It reads commands
30
// from standard input on a worker thread, dispatches them to registered
31
// handlers, and provides a reusable yes/no confirmation flow. Both qmlprofiler
32
// and qmlpreview drive their interactive modes through this class.
33
class
QQmlDebugConsole
:
public
QObject
34
{
35
Q_OBJECT
36
public
:
37
using
CommandHandler
=
std
::
function
<
void
(
const
QStringList
&
args
)>;
38
39
explicit
QQmlDebugConsole
(QObject *parent =
nullptr
);
40
~
QQmlDebugConsole
();
41
42
void
registerCommand
(
const
QStringList &names,
const
QString &argsHint,
43
const
QString &description, CommandHandler handler);
44
45
void
start
();
46
void
stop
();
47
48
void
prompt
(
const
QString &message = QString(),
bool
ready =
true
);
49
void
printLine
(
const
QString &message);
50
51
void
askConfirmation
(
const
QString &question,
std
::function<
void
()> onConfirmed,
52
std
::function<
void
()> onDeclined = {});
53
54
Q_SIGNALS
:
55
void
requestCommand
();
56
// Emitted when standard input is closed (EOF). Consumers typically quit.
57
void
endOfInput
();
58
59
private
:
60
struct
Command
61
{
62
QStringList names;
63
QString argsHint;
64
QString description;
65
CommandHandler handler;
66
};
67
68
void
handleLine(
const
QString &line);
69
void
printHelp();
70
71
QThread m_listenerThread;
72
QQmlDebugCommandListener *m_listener =
nullptr
;
73
74
QList<Command> m_commands;
75
76
QString m_pendingQuestion;
77
std
::function<
void
()> m_onConfirmed;
78
std
::function<
void
()> m_onDeclined;
79
};
80
81
QT_END_NAMESPACE
82
83
#
endif
// QQMLDEBUGCONSOLE_P_H
QQmlDebugConsole
Definition
qqmldebugconsole_p.h:34
QQmlDebugConsole::askConfirmation
void askConfirmation(const QString &question, std::function< void()> onConfirmed, std::function< void()> onDeclined={})
Definition
qqmldebugconsole.cpp:74
QQmlDebugConsole::QQmlDebugConsole
QQmlDebugConsole(QObject *parent=nullptr)
Definition
qqmldebugconsole.cpp:14
QQmlDebugConsole::stop
void stop()
Definition
qqmldebugconsole.cpp:48
QQmlDebugConsole::printLine
void printLine(const QString &message)
Definition
qqmldebugconsole.cpp:69
QQmlDebugConsole::registerCommand
void registerCommand(const QStringList &names, const QString &argsHint, const QString &description, CommandHandler handler)
Definition
qqmldebugconsole.cpp:28
QQmlDebugConsole::start
void start()
Definition
qqmldebugconsole.cpp:34
QQmlDebugConsole::endOfInput
void endOfInput()
QQmlDebugConsole::prompt
void prompt(const QString &message=QString(), bool ready=true)
Definition
qqmldebugconsole.cpp:60
QQmlDebugConsole::~QQmlDebugConsole
~QQmlDebugConsole()
Definition
qqmldebugconsole.cpp:23
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
qtdeclarative
src
qmldebug
qqmldebugconsole_p.h
Generated on
for Qt by
1.18.0