@Afterwork said:
I recreate them every time. Are there better way ?
If they change then there's no way around it but if they're the same every frame then it's a waste of time. Generate the list once, store it as a class member and just expose them by reference e.g.
//split that to .h and .cpp of course class GameWidget : public QWidget { Q_OBJECT public: GameWidget(QWidget* parent = nullptr) : QWidget(parent) { generateMyListOfObjects(); } const QVector<Object>& objects() const { return objects_; } private: void generateMyListOfObjects() { //fill the objects vector here } QVector<Object> objects_; };And how i can connect the slot of differents objects to built-in timer of QWidget ?
You don't. As I said - reimplement the timerEvent method. It will be called every time the timer times out. You can call some methods directly in it or emit a custom signal if you'd like.