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[])
{
pItem.setPlainText("This is a text");
scene.addItem(&pItem);
view.show();
double i = 0;
while(i<std::numeric_limits<int>::max())
{
pItem.
setPlainText(strText
+ QString::number(i
));
i++;
}
scene.removeItem(&pItem);
return a.exec();
}
#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();
}
To copy to clipboard, switch view to plain text mode
I am using Qt 4.6.2 on windows vista
visual studio 2008.
tia,
Bookmarks