Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Load Values of QVector only once when function get called
Forum Update on Tuesday, May 27th 2025

Load Values of QVector only once when function get called

Scheduled Pinned Locked Moved Unsolved General and Desktop
qvectorglobalfunction
3 Posts 2 Posters 416 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MEsc
    wrote on last edited by
    #1

    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?

    JonBJ 1 Reply Last reply
    0
    • M MEsc

      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?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @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!

      M 1 Reply Last reply
      3
      • JonBJ JonB

        @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!

        M Offline
        M Offline
        MEsc
        wrote on last edited by
        #3

        @JonB hello, yes I am an beginner in programming. I have like 2 months experience with it. Would you give me an example for my problem please ?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved