Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. (Solved) Removing square (objects) from my GUI
Forum Updated to NodeBB v4.3 + New Features

(Solved) Removing square (objects) from my GUI

Scheduled Pinned Locked Moved Game Development
6 Posts 2 Posters 1.9k Views 1 Watching
  • 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.
  • U Offline
    U Offline
    u-will-neva-no
    wrote on last edited by
    #1

    Hi everyone. I currently have a .txt file which has a list of (x,y) coordinates. I read this and create square objects and display to the screen. I have a for loop that loops through all the x,y coordinates in the .txt file and generates the objects such as:

    @ for (unsigned int i = 0; i < coordinatesTextFile.size(); i++){
    //convert local coordinates to GUI coordinates

        DisplayObjects *obstacle = new DisplayObjects(((coordinatesTextFile[i][0]-1)*(screenLength/xSquareSize)),((coordinatesTextFile[i][1]-1)*(screenWidth/ySquareSize)-1));
    
        scene->addItem(obstacle);
       
    }@
    

    I want to be able to delete/add old/new coordinates from my .txt file and have the square objects show the result dynamically. Currently I have to close the GUI and re-run the program.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      One way to do it:

      • QFileSystemWatcher to get notifications when the file is modified.
      • Re-read the file
      • Update your coordinate list
      • Update your scene

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • U Offline
        U Offline
        u-will-neva-no
        wrote on last edited by
        #3

        Brilliant, thank you SGaist!

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You're welcome !

          If this answers your question, please update the thread title prepending solved so other forum users may know a solution has been found :)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • U Offline
            U Offline
            u-will-neva-no
            wrote on last edited by
            #5

            Hi SGaist, just to check, I edited the title to include (Solved). Is this what you meant?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Exactly yes :)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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