Results 1 to 3 of 3

Thread: QGraphicsTextItem setPlainText Memory issue

  1. #1
    Join Date
    Oct 2009
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default QGraphicsTextItem setPlainText Memory issue

    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.
    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include <QGraphicsView>
    3. #include <QGraphicsTextItem>
    4. #include <QTimer>
    5. #include <limits>
    6.  
    7.  
    8. int main(int argc, char *argv[])
    9. {
    10. QApplication a(argc, argv);
    11. QGraphicsView view(&scene);
    12. pItem.setPlainText("This is a text");
    13. scene.addItem(&pItem);
    14. view.show();
    15. QString strText("text");
    16. double i = 0;
    17. while(i<std::numeric_limits<int>::max())
    18. {
    19. pItem.setPlainText(strText + QString::number(i));
    20. QApplication::processEvents();
    21. i++;
    22. }
    23. scene.removeItem(&pItem);
    24. return a.exec();
    25. }
    To copy to clipboard, switch view to plain text mode 

    I am using Qt 4.6.2 on windows vista
    visual studio 2008.

    tia,

  2. #2
    Join Date
    Oct 2009
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: QGraphicsTextItem setPlainText Memory issue


  3. #3
    Join Date
    Apr 2008
    Posts
    35
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsTextItem setPlainText Memory issue

    why are you using QGraphicsView/Scene/TextItem ?? or is this just a small part of some other project?? wouldnt QLabel be faster and easier to implement..

Similar Threads

  1. Replies: 2
    Last Post: 18th February 2010, 15:57
  2. Memory Leak Issue
    By linuxdev in forum Qt Programming
    Replies: 10
    Last Post: 1st December 2009, 15:21
  3. MDI application memory issue
    By sirQit in forum Qt Programming
    Replies: 7
    Last Post: 8th July 2009, 19:32
  4. Qt layout memory issue
    By bunjee in forum Qt Programming
    Replies: 9
    Last Post: 25th August 2007, 17:11
  5. Replies: 5
    Last Post: 20th June 2006, 19:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.