Results 1 to 8 of 8

Thread: Timer update as I add objects

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2020
    Posts
    4
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Timer update as I add objects

    Im sorry about the quality of the code, I was changing bit values its true it was first as you described but the animation doesn't start, it does only when I use the private CurrentBuilder but it saves the older spheres created
    in the constructor I assign the _CurrentBuilder passed in the arguments to the private attribute of the class

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,328
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Timer update as I add objects

    You are also passing in the _CurrentBuilder QVector -by value-, which means it is making a copy of the argument you call it with. So the QVector you are modifying is the copy, not the original. If you want to avoid this, call it with QVector<> & _CurrentBuilder.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jun 2020
    Posts
    4
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Timer update as I add objects

    I fixed to use the reference instead of the copy but the problem persists, I think it is the way I show the spheres that causes the problem, each time it passes the QEntity(with all the spheres included) to the rootEntity
    it draws them and then it adds another one while timeout is happening, but this logically would save the older spheres and this is what happens, if anyone has an idea how I can remove old QEntities from the rootEntity probably that would solve the issue

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,328
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Timer update as I add objects

    if anyone has an idea how I can remove old QEntities from the rootEntity probably that would solve the issue
    I think you can just call deleteLater() on the entity pointer. From what I can read of the QNode / QEntity documentation, there are no explicit methods to remove child nodes, but since QNode inherits from QObject, it has the same behavior - simply delete the child and the QObject parent - child relationship takes care of the cleanup. Use deleteLater(), not delete() so that QObject can perform a proper cleanup (and so your program doesn't crash because the pointer has been deleted before Qt has cleaned up references to it).

    If you are having a problem with identifying the spheres you want to delete, then you probably need to keep an extra data structure that stores them when you create them.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 6
    Last Post: 4th September 2014, 09:06
  2. Threads, Timer and Update a Field
    By lima_will in forum Newbie
    Replies: 2
    Last Post: 2nd October 2013, 08:05
  3. single timer for multiple objects
    By prabhatjha in forum Newbie
    Replies: 8
    Last Post: 30th August 2013, 08:54
  4. timer problem(timer does not work)
    By masuk in forum Newbie
    Replies: 6
    Last Post: 14th February 2011, 05:00
  5. Replies: 7
    Last Post: 18th July 2006, 21:33

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.