Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
main.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 <QtCore>
5#include <QByteArray>
6#include <QDataStream>
7
16
19{
20 out << (quint32)movie.id << movie.title
21 << movie.releaseDate;
22 return out;
23}
25
28{
29 quint32 id;
30 QDate date;
31
32 in >> id >> movie.title >> date;
33 movie.id = (int)id;
34 movie.releaseDate = date;
35 return in;
36}
38
39int main(int argc, char *argv[])
40{
41 QCoreApplication app(argc, argv);
42
43 Movie m;
44 m.id = 0001;
45 m.title = "Happy Meal";
46 m.releaseDate = QDate(1995, 5, 17);
47
48 QByteArray byteArray;
50 stream << m;
51
52 // display
53 qDebug() << m.id << m.releaseDate << m.title;
54
55 Movie m2;
56
57 int id2;
58 QString title2;
59 QDate date2;
60
61 QDataStream stream2(byteArray);
62 stream2 >> id2 >> title2 >> date2;
63
64 m2.id = id2;
65 m2.title = title2;
66 m2.releaseDate = date2;
67
68 qDebug() << id2 << " " << date2 << " " << title2;
69
70 return 0;
71}
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
\inmodule QtCore\reentrant
Definition qdatastream.h:46
\inmodule QtCore \reentrant
Definition qdatetime.h:29
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
int main()
[0]
QDate date
[1]
EGLStreamKHR stream
#define qDebug
[1]
Definition qlogging.h:164
const GLfloat * m
GLenum GLuint id
[7]
GLuint in
QDebug operator<<(QDebug &debug, const UsbEntry &entry)
Definition main.cpp:25
QDataStream & operator>>(QDataStream &in, Movie &movie)
[1]
Definition main.cpp:27
unsigned int quint32
Definition qtypes.h:50
QTextStream out(stdout)
[7]
QApplication app(argc, argv)
[0]
[0]
Definition main.cpp:10
int id
Definition main.cpp:11
QDate releaseDate
Definition main.cpp:13
QString title
Definition main.cpp:12