decin
9th March 2010, 07:46
Hi,
I am using QGraphicsTextItem to display a text that is continiously being updated at a given time interval. i am calling the setPlainText to set the text. It is observed on each call to setPlainText the memory used by the application keeps increasing.
Below is a sample code where this issue can be noticed. you can notice the memory used by the application in windows task manager.
#include <QtGui/QApplication>
#include <QGraphicsView>
#include <QGraphicsTextItem>
#include <QTimer>
#include <limits>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QGraphicsScene scene;
QGraphicsView view(&scene);
QGraphicsTextItem pItem ;
pItem.setPlainText("This is a text");
scene.addItem(&pItem);
view.show();
QString strText("text");
double i = 0;
while(i<std::numeric_limits<int>::max())
{
pItem.setPlainText(strText + QString::number(i));
QApplication::processEvents();
i++;
}
scene.removeItem(&pItem);
return a.exec();
}
I am using Qt 4.6.2 on windows vista
visual studio 2008.
tia,
I am using QGraphicsTextItem to display a text that is continiously being updated at a given time interval. i am calling the setPlainText to set the text. It is observed on each call to setPlainText the memory used by the application keeps increasing.
Below is a sample code where this issue can be noticed. you can notice the memory used by the application in windows task manager.
#include <QtGui/QApplication>
#include <QGraphicsView>
#include <QGraphicsTextItem>
#include <QTimer>
#include <limits>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QGraphicsScene scene;
QGraphicsView view(&scene);
QGraphicsTextItem pItem ;
pItem.setPlainText("This is a text");
scene.addItem(&pItem);
view.show();
QString strText("text");
double i = 0;
while(i<std::numeric_limits<int>::max())
{
pItem.setPlainText(strText + QString::number(i));
QApplication::processEvents();
i++;
}
scene.removeItem(&pItem);
return a.exec();
}
I am using Qt 4.6.2 on windows vista
visual studio 2008.
tia,