Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How I can delete QQueue delete items older than 5 seconds ?
What is the best paroach to delete item in a QQueue (or in Qvector) older than 5 seconds . ? Something like time to Live for object..
QQueue being a FIFO structure, its not really good for random access.
How many items will the container have ?
@RahibeMeryem Why do you need this? What is the use case?
You will have to implement this by yourself. For example, each object could emit a signal after 5 seconds (using a QTimer) and the slot connected to it would then delete it.
I want to put plate / object names to the screen. If plate or objects is seen before such as in 5 or 10 second I want to pass dont want to print names.
@RahibeMeryem This is not a task for a container like QQueue.
You can use a map.
std::map<QString, QTime> UsedNames.
Then when you are about to display a Name,
check if its in map,
if yes, check timestamp , and decided if show again,
if not in list, simply add (with timestamp) and display on screen.
If in list and expired, replace in map with new timestamp for the wanted timeout.
something like that ;)
Well it really depends how fast you need to draw new strings and check
but if any human must have time to read it, i think it will be plenty fast.
I used QHash it looks faster look up than map.