[Qt-interest] global variables new and delete
John McClurkin
jwm at nei.nih.gov
Thu Sep 10 18:09:21 CEST 2009
Serge wrote:
> Hello,
> please help me to understand how to do it correctly:
>
> i have file globals.h with lines:
> class MyClass;
> namespace globals
> {
> extern MyClass *myPtr;
> }
>
> in globals.cpp:
> MyClass *globals::myPtr=NULL;
>
> where can i create by "new" this object and delete by "delete"?
> so that it would be created before all widgets of my app created and
> destroyed on application close after all widgets destroyed?
>
> main.cpp contains lines:
>
> QApplication a( argc, argv );
globals::myPtr = new MyClass();
> return a.exec();
>
delete globals::myPtr;
return 0;
> --
> Serge
More information about the Qt-interest-old
mailing list