From 281ec272d81e31eb0bfd1a25ddd79751f0c9be67 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Sun, 19 Apr 2020 09:47:42 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=81=D0=B5=20=D0=B0=D0=B2=D1=82=D0=BE?= =?UTF-8?q?=D0=B7=D0=B0=D0=BC=D0=B5=D0=BD=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cmlib-example/fsh.hpp | 11 +++++++++++ src/cmlib-example/main.cpp | 19 ++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 src/cmlib-example/fsh.hpp diff --git a/src/cmlib-example/fsh.hpp b/src/cmlib-example/fsh.hpp new file mode 100644 index 0000000..9db3a41 --- /dev/null +++ b/src/cmlib-example/fsh.hpp @@ -0,0 +1,11 @@ +#pragma once + +#include + +class FileSignalHandler : public QObject { + Q_OBJECT +public: + Q_SLOT void process() {}; +}; + + diff --git a/src/cmlib-example/main.cpp b/src/cmlib-example/main.cpp index 2a8458d..3175798 100644 --- a/src/cmlib-example/main.cpp +++ b/src/cmlib-example/main.cpp @@ -7,14 +7,9 @@ // function args by ref -int sum(QStringList sl) +int qStringToInt(QString s) { - int s = 0; - for(auto str: sl) - { - s += str.toInt(); - } - return s; + return s.toInt(); } @@ -24,15 +19,16 @@ int main( int argc, char** argv ) // qt-keywords QList il; - il << 111 << 222 << 333; + il << 111 << 222; foreach(int i, il) { qDebug() << i; } - // loop add ref QStringList sl; - sl << "111" << "222" << "333"; + // string allocations + sl << "111" << "222"; + // loop add ref for (const auto &s: sl) { qDebug() << s; @@ -45,7 +41,8 @@ int main( int argc, char** argv ) } // function args by ref - auto ir = sum(sl); + QString s { "100" }; + auto ir = qStringToInt(s); // old style connect QFile f;