[solved] QTimer in console application
-
[quote author="hskoglund" date="1423561353"]You don't need any parenthesis when lambda has no arguments, "learned that":http://qt-project.org/forums/viewreply/216748/ from JKSH the other day :-)[/quote]Pay it forward! ;-)
-
not sure it makes sense to add to an already solved topic (?)
in above lecture the main reason i did not solve the problem myself
by trial & error was Chris' hint to use
@CONFIG += c++11@in .pro file.
It's mentioned here "docs":http://doc.qt.io/qt-5/qmake-variable-reference.html#config
but this is not really an explanation.
Where can i find an explanation what this instruction really effects
and in which cases to use ? -
[quote author="wally123" date="1423669903"]not sure it makes sense to add to an already solved topic (?)[/quote]That's perfectly ok if you are continuing to discuss the same topic.
[quote author="wally123" date="1423669903"]in above lecture the main reason i did not solve the problem myself
by trial & error was Chris' hint to use
@CONFIG += c++11@in .pro file.
It's mentioned here "docs":http://doc.qt.io/qt-5/qmake-variable-reference.html#config
but this is not really an explanation.
Where can i find an explanation what this instruction really effects
and in which cases to use ?
[/quote]That instructions tells your compiler to enable "C++11":http://www.cprogramming.com/c++11/what-is-c++0x.html features.The QTimer code that Chris posted uses a lambda expression, which was introduced in C++11; that's why you need that command.
-
[quote author="wally123" date="1423671202"]thx
needless to say which expression is now in center of interest :)
λ [/quote]You're welcome! It's a very nice toy indeed. Once you learn how to use it, I'm sure you'll be using it lots. ;)Lambda expressions make it much easier to write event-driven code in Qt. If your slot is only used in one place, you can define it as a lambda right in the "connect" statement. No need to create a separate function in your class anymore. See "Making Connections to Lambda Expressions":http://doc.qt.io/qt-5/signalsandslots-syntaxes.html#making-connections-to-lambda-expressions.
Happy coding!
-
The doc pretty much says everything there is to say about it but I'll try to expand.
As you may or may not know C++ goes through revisions and different compilers have varying support for the latest standard.
In case of GCC the default is c++03 and to enable the latest c++11 you need a compiler param -std=c++11. To make this portable across compilers qmake exposes this as the above CONFIG switch and does the right thing for the given compiler to enable c++11 support.Lambdas (or captures or anonymous functions as they are also known) are new part of c++11 standard.
"Here":https://gcc.gnu.org/projects/cxx0x.html is a comprehensive table listing all the new features of c++11 and which gcc version supports what.Oh, the next revision of c++ has been already voted in last year so expect something like CONFIG+=c++14 available pretty soon.
As for which c++11/14 features are supported/used by Qt you can travel the net, e.g. "here":http://woboq.com/blog/cpp11-in-qt5.html or "here":http://woboq.com/blog/cpp14-in-qt.html
-
Don't know about others but I pretty much operate on a "beerware":http://en.wikipedia.org/wiki/Beerware based rules.
-
[quote author="wally123" date="1423672274"]This forum is really incredible efficient for learning ![/quote]It is. :) We hope that one day, when you're a Qt veteran, you'll come back and help newcomers too!
[quote author="wally123" date="1423672274"]btw.: does anybody pay you for your time and sharing knowhow ?[/quote]I suppose I get paid in pats-on-the-back, satisfaction, reputation, and knowledge + experience.
I often learn new things while doing research to answer a question. In turn, that helps me produce better code, which makes my customers happy, so they keep paying me.
BTW, it's not limited to this forum; the hacker community is full of volunteers, e.g. "StackOverflow":http://stackoverflow.com/