Results 1 to 6 of 6

Thread: Memory problem in QScrollArea.

  1. #1
    Join Date
    Jul 2013
    Posts
    72
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Memory problem in QScrollArea.

    Hi, in my program I use QicsTable as a container, and put it into a qscrollarea, but as the size of the table's cell getting bigger, memory is consuming more. I think the qscrollarea seems the table's cell as an unit, and paint the whole cell all the time.

    Is there any way to optimize it ?


    Below is a simple example, which costs memory up to 280m. And sometimes i need the size to be (300, 167010), in this case memory cost(up to 1G) is unacceptable.
    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication a(argc, argv);
    4. QMainWindow window;
    5.  
    6. QicsDataModel *dmPlots = new QicsDataModelDefault(1, 4);
    7.  
    8. QicsTable *tables = new QicsTable(dmPlots);
    9.  
    10. for (int i = 0; i < 4; i++) {
    11. tables->cellRef(0, i).setWidthInPixels(300);
    12. tables->cellRef(0, i).setHeightInPixels(32000);
    13. }
    14.  
    15. QScrollArea *area = new QScrollArea();
    16.  
    17. area->setWidget(tables);
    18.  
    19. area->setFixedWidth(300);
    20. window.setCentralWidget(area);
    21. window.resize( 400, 600 );
    22. window.show();
    23. return a.exec();
    24. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by anda_skoa; 29th September 2014 at 11:59. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Memory problem in QScrollArea.

    Why do you need the scroll area?

    Cheers,
    _

  3. #3
    Join Date
    Jul 2013
    Posts
    72
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Memory problem in QScrollArea.

    The cell size is too big.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Memory problem in QScrollArea.

    Doesn't the table have its own scrollbars?

    Anyway a quick calculation indicates a pixmap containing a single table cell occupies around 150MB of ram. I don't know how the table works but it may be caching cell renders for quick repaints in which case your problem is unrelated to the scroll area. Does removing it help with memory consumption?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jul 2013
    Posts
    72
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Memory problem in QScrollArea.

    The table has its own scrollbars but it's minimal step is one cell.
    My program is to use a big cell which needs scroll bar, so I set it into a scroll area.

    Memory consumption is OK without the table, however , I need some attributes of the table.

    Are you suggesting looking into the table rather than scroll area ?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Memory problem in QScrollArea.

    Quote Originally Posted by lwz View Post
    The table has its own scrollbars but it's minimal step is one cell.
    I'm sure you can change that by overriding some method or modifying singleStep property in the scroll bar.

    Memory consumption is OK without the table, however , I need some attributes of the table.
    I was rather asking about removing the scroll area as you seem to imply it is the scroll area that causes the memory usage to be so large.

    Are you suggesting looking into the table rather than scroll area ?
    I suggest to rethink the idea of having table cells so large.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QScrollArea Memory Leak
    By rossimo in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 5th November 2010, 10:41
  2. QScrollArea inner widget problem
    By agaf in forum Qt Programming
    Replies: 3
    Last Post: 19th January 2010, 18:06
  3. Simple QScrollArea problem
    By jmsbc in forum Qt Programming
    Replies: 4
    Last Post: 2nd December 2008, 18:45
  4. qscrollarea slider problem
    By babu198649 in forum Qt Programming
    Replies: 4
    Last Post: 22nd November 2007, 12:51
  5. Problem with QScrollArea updating from 4.0.1 to 4.1.0
    By SkripT in forum Qt Programming
    Replies: 8
    Last Post: 28th January 2006, 22:35

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.