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

Load Values of QVector only once when function get called

Scheduled Pinned Locked Moved Unsolved General and Desktop
qvectorglobalfunction
3 Posts 2 Posters 413 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 21 Nov 2022, 09:32 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?

    J 1 Reply Last reply 21 Nov 2022, 09:39
    0
    • M MEsc
      21 Nov 2022, 09:32

      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?

      J Offline
      J Offline
      JonB
      wrote on 21 Nov 2022, 09:39 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 21 Nov 2022, 13:14
      3
      • J JonB
        21 Nov 2022, 09:39

        @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 21 Nov 2022, 13:14 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

        1/3

        21 Nov 2022, 09:32

        • Login

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