4#include <QMetaProperty>
20 Q_DECLARE_FLAGS(Options,
Option)
24Q_DECLARE_OPERATORS_FOR_FLAGS(
MyClass_1::Options)
38 Q_DECLARE_FLAGS(Options, Option)
43Q_DECLARE_OPERATORS_FOR_FLAGS(
MyClass_2::Options)
61 typedef QFlags<Enum> Flags;
66 qWarning(
"QSqlQuery::exec: database not open");
73 qint64 value = Q_INT64_C(932838457459459);
79 quint64 value = Q_UINT64_C(932838457459459);
85 qint64 value = Q_INT64_C(932838457459459);
91 quint64 value = Q_UINT64_C(932838457459459);
100 absoluteValue = qAbs(myValue);
110 int roundedValueA = qRound(valueA);
112 int roundedValueB = qRound(valueB);
122 int roundedValueA = qRound(valueA);
124 int roundedValueB = qRound(valueB);
131 double valueA = 42949672960.3;
132 double valueB = 42949672960.7;
134 qint64 roundedValueA = qRound64(valueA);
136 qint64 roundedValueB = qRound64(valueB);
143 float valueA = 42949672960.3f;
144 float valueB = 42949672960.7f;
146 qint64 roundedValueA = qRound64(valueA);
148 qint64 roundedValueB = qRound64(valueB);
158 int minValue = qMin(myValue, yourValue);
168 int maxValue = qMax(myValue, yourValue);
179 int boundedValue = qBound(minValue, myValue, maxValue);
202 Q_ASSERT_X(b != 0,
"divide",
"division by zero");
212ASSERT:
"b != 0" in file div.cpp, line 7
216ASSERT failure in divide:
"division by zero", file div.cpp, line 7
226 Q_CHECK_PTR(a =
new int[80]);
228 a =
new (std::nothrow)
int[80];
234template<
typename TInputType>
235const TInputType &
myMin(
const TInputType &value1,
const TInputType &value2)
237 qDebug() << Q_FUNC_INFO <<
"was called with value1:" << value1 <<
"value2:" << value2;
250 QBrush myQBrush(Qt::red);
253 qDebug(
"Items in list: %d", myList.size());
258 qDebug() <<
"Brush:" << myQBrush <<
"Other value:" << i;
263 qInfo(
"Items in list: %d", myList.size());
267 qInfo() <<
"Brush:" << myQBrush <<
"Other value:" << i;
275 qWarning(
"f: bad argument, c == %d", c);
281 QBrush myQBrush(Qt::red);
284 qWarning() <<
"Brush:" << myQBrush <<
"Other value:" << i;
289void load(
const QString &fileName)
291 QFile file(fileName);
293 qCritical(
"File '%s' does not exist!", qUtf8Printable(fileName));
299 QBrush myQBrush(Qt::red);
302 qCritical() <<
"Brush:" << myQBrush <<
"Other value:" << i;
310 qFatal(
"divide: cannot divide by zero");
346 static const char *greeting_strings[] = {
348 QT_TR_NOOP(
"Goodbye")
350 return tr(greeting_strings[type]);
371 QT_TR_N_NOOP(
"There are %n new message(s)"),
372 QT_TR_N_NOOP(
"There are %n total message(s)")
377 return tr(status_strings[type],
nullptr, count);
389 QT_TRANSLATE_N_NOOP(
"Welcome Msg",
"Hello, you have %n message(s)"),
390 QT_TRANSLATE_N_NOOP(
"Welcome Msg",
"Hi, you have %n message(s)")
395 return translate(
"Welcome Msg", greeting_strings[type],
nullptr, msgcnt);
406 QString text = qtTrId(
"qtn_foo_bar", n);
414 static const char *
const ids[] = {
416 QT_TRID_N_NOOP(
"qtn_foo"),
418 QT_TRID_N_NOOP(
"qtn_bar"),
424 return qtTrId(
ids[type], n);
452 int x()
const {
return data[0]; }
453 int y()
const {
return data[1]; }
464#if Q_BYTE_ORDER == Q_BIG_ENDIAN
470#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
479#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
487#if Q_BYTE_ORDER == Q_BIG_ENDIAN
517 MyClass(
const MyClass &) =
delete;
527 qFuzzyCompare(0.0, 1.0e-200);
529 qFuzzyCompare(1 + 0.0, 1 + 1.0e-200);
571 auto ptr_1 = qConstOverload<
int,
const QString &>(&Foo::overloadedFunction);
572 auto ptr_2 = qNonConstOverload<
int,
const QString &>(&Foo::overloadedFunction);
584 for (
int i = 1; i <= 365; i++) {
597 if (Q_UNLIKELY(!file.exists())) {
598 qWarning() <<
"File not found";
641 const char *varName =
"MY_ENV_VAR";
645 bool is_empty = qgetenv(varName).isEmpty();
649 int to_int = qgetenv(varName).toInt(ok, 0);
653 auto value = qEnvironmentVariableIntegerValue(varName).value_or(0);
657 bool equals_zero = qEnvironmentVariableIntegerValue(varName) == 0;
661 bool is_not_null = !qgetenv(varName).isNull();
667 return "Hello, World!";
674#if QT_DEPRECATED_SINCE(6
, 6
)
680 for (QChar ch : qAsConst(s))
687 const QString s =
"...";
693 for (QChar ch : funcReturningQString())
699 for (QChar ch : qAsConst(funcReturningQString()))
704 for (QChar ch : qAsConst(funcReturningQString()))
virtual void final_func() final
[qdeclfinal-1]
Point2D(const Point2D &other)
Point2D & operator=(const Point2D &other)
QString greeting(int type)
[34]
static const char *const status_strings[]
[qttrnnoop]
static QString status(int type, int count)
QString result(int type, int n)
static const char *const ids[]
[qttrid_n_noop]
QString tr(const char *, const char *, int)
void debug_info_example()
[22]
void qttrid_example()
[qttranslatennoop]
static const char *const greeting_strings[]
[qttranslatennoop]
void warning_example()
[26]
QString translate(const char *, const char *, const char *, int)
int qunreachable_example(Shapes shape)
void load(const QString &fileName)
[28]
void qfuzzycompare_example()
[44]
int divide(int a, int b)
[17&19_include_open]
const TInputType & myMin(const TInputType &value1, const TInputType &value2)
[22]
QString global_greeting(int type, int msgcnt)
void critical_example()
[28]
Q_DECLARE_TYPEINFO(Point3D, Q_PRIMITIVE_TYPE)
void myMessageHandler(QtMsgType, const QMessageLogContext &, const QString &)
[49]
Q_DECLARE_TYPEINFO(Point2D, Q_RELOCATABLE_TYPE)
int rectangle()
[qunreachable-enum]
int divide_by_zero(int a, int b)
[30]
void pointer_example()
[17&19_return_close]
bool readConfiguration(const QFile &file)
[qunlikely]
void process(const QChar &ch)
bool isWorkingDay(int day)
[54]
QString funcReturningQString()
void forever_example()
[30]
void overloadedFunction(int, const QString &) const
void overloadedFunction(int, const QString &)
void overloadedFunction(int, const QString &)
void overloadedFunction()