[Qt-interest] replace QCoreApplication by QApplication?

Andreas Pakulat apaku at gmx.de
Sun Aug 30 14:27:12 CEST 2009


On 30.08.09 12:40:10, Alexander Poddey wrote:
> 
> hi thiago,
> 
> thank you for your answer.
> the extra curly brakets around QCoreApplication solved the problem.
> why that?

Because curly braces create scope in C++. So you created an "unnamed"
scope in which you created a QCoreApplication instance called app on the
stack. Once a scope is exited (the closing curly brace) all variables
declared inside the scope go "out of scope" and hence your
QCoreApplication object is destroyed.

> both, reusing 'app' or using 'app' and 'appgui' works. which way is 
> preferable? 

Whatever you prefer.

Andreas

-- 
Today is National Existential Ennui Awareness Day.



More information about the Qt-interest-old mailing list