tonnot
16th February 2011, 13:46
I see how works the menu system at tutorial 'recent files'.
( This is a piece of code)
at .h
enum { MaxRecentFiles = 5 };
QAction *recentFileActs[MaxRecentFiles];
at .cpp
recentFilesActs[0]= new QAction("a_string", this);
There is not problem in having recentFileActs with 5 'reserved' QActions
But, if I didnt want to have 'reserved' space and want to create at .cpp ?
It is a basic c++ question but I dont know how to do it. It is related with 'How can I create an array of objects that have a constructor parameter'.
At h.file I want : QAction *recentFileActs[];
and at .cpp : ???? code for variable and exact value
I can't write recentFileActs = new QActions(20);
1.- Have I to create a QAction by pointer and later to pass it to recentFileActs[0] ?
2.- In that case must I to keep in mind that I have to delete the objects created?
Thanks
( This is a piece of code)
at .h
enum { MaxRecentFiles = 5 };
QAction *recentFileActs[MaxRecentFiles];
at .cpp
recentFilesActs[0]= new QAction("a_string", this);
There is not problem in having recentFileActs with 5 'reserved' QActions
But, if I didnt want to have 'reserved' space and want to create at .cpp ?
It is a basic c++ question but I dont know how to do it. It is related with 'How can I create an array of objects that have a constructor parameter'.
At h.file I want : QAction *recentFileActs[];
and at .cpp : ???? code for variable and exact value
I can't write recentFileActs = new QActions(20);
1.- Have I to create a QAction by pointer and later to pass it to recentFileActs[0] ?
2.- In that case must I to keep in mind that I have to delete the objects created?
Thanks