Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
7class Coordinate : public QObject
8{
9public:
10 int myX, myY;
11
12 int x() const { return myX; };
13 int y() const { return myY; };
14};
15
16//! [0]
17QDebug operator<<(QDebug debug, const Coordinate &c)
18{
19 QDebugStateSaver saver(debug);
20 debug.nospace() << '(' << c.x() << ", " << c.y() << ')';
21
22 return debug;
23}
24//! [0]
25
26int main(int argv, char **args)
27{
28 Coordinate coordinate;
29 coordinate.myX = 10;
30 coordinate.myY = 44;
31
32//! [1]
33 qDebug() << "Date:" << QDate::currentDate();
34 qDebug() << "Types:" << QString("String") << QChar('x') << QRect(0, 10, 50, 40);
35 qDebug() << "Custom coordinate type:" << coordinate;
36//! [1]
37}
int x() const
int y() const
QDebug operator<<(QDebug debug, const Coordinate &c)
[0]
int main(int argc, char *argv[])
[ctor_close]