jano_alex_es
8th January 2010, 14:02
Hi, I have the next code, as far as I've seen, pretty similar to the normal usage of QTimer.
QTimer* pAuxTimer = new QTimer();
pAuxTimer->setSingleShot(true);
QSignalMapper* mapper = new QSignalMapper();
connect(pAuxTimer, SIGNAL(timeout()), mapper, SLOT(map()));
connect(mapper, SIGNAL(mapped(QWidget*)), this, SLOT(showTranspAdvertisement(QWidget*)));
mapper->setMapping(pAuxTimer, pAuxWid);
pAuxTimer->start(50);
It works fine, but it creates a memory leak because that's the end of the function. I can use a non local variable because the code is executed when the user presses a button, so I don't know how many times is gonne be executed, I don't know how many timers I'm gonna have working at the same time...
Does Qt eliminate them automatically? docs says nothing about that.
thansk!
QTimer* pAuxTimer = new QTimer();
pAuxTimer->setSingleShot(true);
QSignalMapper* mapper = new QSignalMapper();
connect(pAuxTimer, SIGNAL(timeout()), mapper, SLOT(map()));
connect(mapper, SIGNAL(mapped(QWidget*)), this, SLOT(showTranspAdvertisement(QWidget*)));
mapper->setMapping(pAuxTimer, pAuxWid);
pAuxTimer->start(50);
It works fine, but it creates a memory leak because that's the end of the function. I can use a non local variable because the code is executed when the user presses a button, so I don't know how many times is gonne be executed, I don't know how many timers I'm gonna have working at the same time...
Does Qt eliminate them automatically? docs says nothing about that.
thansk!