Qt
6.x
The Qt SDK
Loading...
Searching...
No Matches
qdebugsnippet.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4
#include <QtGui>
5
#include <QtDebug>
6
7
class
Coordinate
:
public
QObject
8
{
9
public
:
10
int
myX
,
myY
;
11
12
int
x
()
const
{
return
myX
; };
13
int
y
()
const
{
return
myY
; };
14
};
15
17
QDebug
operator<<
(
QDebug
debug
,
const
Coordinate
&
c
)
18
{
19
QDebugStateSaver
saver(
debug
);
20
debug
.nospace() <<
'('
<<
c
.x() <<
", "
<<
c
.y() <<
')'
;
21
22
return
debug
;
23
}
25
26
int
main
(
int
argv,
char
**
args
)
27
{
28
Coordinate
coordinate;
29
coordinate.
myX
= 10;
30
coordinate.
myY
= 44;
31
33
qDebug
() <<
"Date:"
<<
QDate::currentDate
();
34
qDebug
() <<
"Types:"
<<
QString
(
"String"
) <<
QChar
(
'x'
) <<
QRect
(0, 10, 50, 40);
35
qDebug
() <<
"Custom coordinate type:"
<< coordinate;
37
}
Coordinate
Definition
qdebugsnippet.cpp:8
Coordinate::x
int x() const
Definition
qdebugsnippet.cpp:12
Coordinate::myX
int myX
Definition
qdebugsnippet.cpp:10
Coordinate::y
int y() const
Definition
qdebugsnippet.cpp:13
Coordinate::myY
int myY
Definition
qdebugsnippet.cpp:10
QChar
\inmodule QtCore
Definition
qchar.h:48
QDate::currentDate
static QDate currentDate()
Returns the system clock's current date.
QDebugStateSaver
\inmodule QtCore
QDebug
\inmodule QtCore
QObject
\inmodule QtCore
Definition
qobject.h:90
QRect
\inmodule QtCore\reentrant
Definition
qrect.h:30
QString
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition
qstring.h:127
main
int main()
[0]
Definition
doc_src_objecttrees.cpp:5
operator<<
QDebug operator<<(QDebug debug, const Coordinate &c)
[0]
Definition
qdebugsnippet.cpp:17
debug
@ debug
Definition
qibusplatforminputcontext.cpp:48
qDebug
#define qDebug
[1]
Definition
qlogging.h:160
c
const GLubyte * c
Definition
qopenglext.h:12701
args
QJSValueList args
Definition
src_script_qjsengine.cpp:12
qtbase
src
corelib
doc
snippets
qdebug
qdebugsnippet.cpp
Generated by
1.9.7