4#include <QMetaProperty>
20 Q_DECLARE_FLAGS(Options,
Option)
24Q_DECLARE_OPERATORS_FOR_FLAGS(
MyClass_1::Options)
48 typedef QFlags<Enum> Flags;
53 qWarning(
"QSqlQuery::exec: database not open");
60 qint64 value = Q_INT64_C(932838457459459);
66 quint64 value = Q_UINT64_C(932838457459459);
72 qint64 value = Q_INT64_C(932838457459459);
78 quint64 value = Q_UINT64_C(932838457459459);
87 absoluteValue = qAbs(myValue);
97 int roundedValueA = qRound(valueA);
99 int roundedValueB = qRound(valueB);
109 int roundedValueA = qRound(valueA);
111 int roundedValueB = qRound(valueB);
118 double valueA = 42949672960.3;
119 double valueB = 42949672960.7;
121 qint64 roundedValueA = qRound64(valueA);
123 qint64 roundedValueB = qRound64(valueB);
130 float valueA = 42949672960.3f;
131 float valueB = 42949672960.7f;
133 qint64 roundedValueA = qRound64(valueA);
135 qint64 roundedValueB = qRound64(valueB);
145 int minValue = qMin(myValue, yourValue);
155 int maxValue = qMax(myValue, yourValue);
166 int boundedValue = qBound(minValue, myValue, maxValue);
189 Q_ASSERT_X(b != 0,
"divide",
"division by zero");
199ASSERT:
"b != 0" in file div.cpp, line 7
203ASSERT failure in divide:
"division by zero", file div.cpp, line 7
213 Q_CHECK_PTR(a =
new int[80]);
215 a =
new (std::nothrow)
int[80];
221template<
typename TInputType>
222const TInputType &
myMin(
const TInputType &value1,
const TInputType &value2)
224 qDebug() << Q_FUNC_INFO <<
"was called with value1:" << value1 <<
"value2:" << value2;
237 QBrush myQBrush(Qt::red);
240 qDebug(
"Items in list: %d", myList.size());
245 qDebug() <<
"Brush:" << myQBrush <<
"Other value:" << i;
250 qInfo(
"Items in list: %d", myList.size());
254 qInfo() <<
"Brush:" << myQBrush <<
"Other value:" << i;
262 qWarning(
"f: bad argument, c == %d", c);
268 QBrush myQBrush(Qt::red);
271 qWarning() <<
"Brush:" << myQBrush <<
"Other value:" << i;
276void load(
const QString &fileName)
278 QFile file(fileName);
280 qCritical(
"File '%s' does not exist!", qUtf8Printable(fileName));
286 QBrush myQBrush(Qt::red);
289 qCritical() <<
"Brush:" << myQBrush <<
"Other value:" << i;
297 qFatal(
"divide: cannot divide by zero");
333 static const char *greeting_strings[] = {
335 QT_TR_NOOP(
"Goodbye")
337 return tr(greeting_strings[type]);
358 QT_TR_N_NOOP(
"There are %n new message(s)"),
359 QT_TR_N_NOOP(
"There are %n total message(s)")
364 return tr(status_strings[type],
nullptr, count);
376 QT_TRANSLATE_N_NOOP(
"Welcome Msg",
"Hello, you have %n message(s)"),
377 QT_TRANSLATE_N_NOOP(
"Welcome Msg",
"Hi, you have %n message(s)")
382 return translate(
"Welcome Msg", greeting_strings[type],
nullptr, msgcnt);
393 QString text = qtTrId(
"qtn_foo_bar", n);
401 static const char *
const ids[] = {
403 QT_TRID_N_NOOP(
"qtn_foo"),
405 QT_TRID_N_NOOP(
"qtn_bar"),
411 return qtTrId(
ids[type], n);
439 int x()
const {
return data[0]; }
440 int y()
const {
return data[1]; }
451#if Q_BYTE_ORDER == Q_BIG_ENDIAN
457#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
466#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
474#if Q_BYTE_ORDER == Q_BIG_ENDIAN
504 MyClass(
const MyClass &) =
delete;
514 qFuzzyCompare(0.0, 1.0e-200);
516 qFuzzyCompare(1 + 0.0, 1 + 1.0e-200);
558 auto ptr_1 = qConstOverload<
int,
const QString &>(&Foo::overloadedFunction);
559 auto ptr_2 = qNonConstOverload<
int,
const QString &>(&Foo::overloadedFunction);
571 for (
int i = 1; i <= 365; i++) {
584 if (Q_UNLIKELY(!file.exists())) {
585 qWarning() <<
"File not found";
628 const char *varName =
"MY_ENV_VAR";
632 bool is_empty = qgetenv(varName).isEmpty();
636 int to_int = qgetenv(varName).toInt(ok, 0);
640 auto value = qEnvironmentVariableIntegerValue(varName).value_or(0);
644 bool equals_zero = qEnvironmentVariableIntegerValue(varName) == 0;
648 bool is_not_null = !qgetenv(varName).isNull();
654 return "Hello, World!";
661#if QT_DEPRECATED_SINCE(6
, 6
)
667 for (QChar ch : qAsConst(s))
674 const QString s =
"...";
680 for (QChar ch : funcReturningQString())
686 for (QChar ch : qAsConst(funcReturningQString()))
691 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()