Load Values of QVector only once when function get called
-
Hello, I have a Question. I am trying to build a vocabeltrainer. Its possible to add new vocabels, which will be stored in 2 files german.txt and english.txt. When I start the game this file will be load in 2 vectors QVector<QString> german and QVector<QString> english. Then it randomly read out one vocabel for example the german one. My problem is everytime I type in the answer in english and it will checked, these to vectors will be load new. If des file stores a lot of vocabels, the performance of the application will get worse. Is there an opportunity that des vectors only load when I start the game?
-
@MEsc said in Load Values of QVector only once when function get called:
Is there an opportunity that des vectors only load when I start the game?
Hello and welcome.
Of course, yes! Read the files in only once. You will likely want to store them in class member variables, in whatever class you are using for this. If you do not know about class member variables in C++ or Python, you need to read up on them first to get anywhere in programming!