Results 1 to 20 of 72

Thread: QGraphicsScene/QGraphicsView performance problems

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: QGraphicsScene/QGraphicsView performance problems

    Create the item on heap.

    Qt Code:
    1. ShapeItem *item = new ShapeItem(...);
    2. scene->addItem(item);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicsScene/QGraphicsView performance problems

    Thanks, now it is working.
    Unfortunately, now the app started gobbling up all memory even for a smaller file, so it got worse. I will have to figure out why...
    MacOSX user dabbling with Linux and Windows.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsScene/QGraphicsView performance problems

    Quote Originally Posted by bnilsson View Post
    Unfortunately, now the app started gobbling up all memory even for a smaller file, so it got worse. I will have to figure out why...
    Use valgrind. The Massif tool might be especially helpful.

  4. #4
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicsScene/QGraphicsView performance problems

    Use valgrind. The Massif tool might be especially helpful.
    For the moment I'm on MacOSX, so this is not applicable.
    MacOSX user dabbling with Linux and Windows.

  5. #5
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicsScene/QGraphicsView performance problems

    The behaviour was a bit better using Qt4.4.0 than Qt4.3.3, so maybe it's not in my code entirely. But still in the 1Gb range for a 40Mb file.
    The behaviour was very strange indeed (excessive cpu and memory load when zooming IN) on my amd46 Debian using Qt4.3.3, and this particular problem was fixed by the Qt4.4.0 snapshot.

    Anyway, standard usage of QGraphicsView/QGraphiscScene was not dramatically improved using Qt4.4.0.
    Last edited by bnilsson; 5th January 2008 at 16:44.
    MacOSX user dabbling with Linux and Windows.

  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: QGraphicsScene/QGraphicsView performance problems

    Could you provide a minimal compilable example reproducing the problem so that we might try it ourselves?

  7. #7
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicsScene/QGraphicsView performance problems

    Sure, the project is not very big, I will try to prepare something.
    I am new to this forum, what are the provisions for uploading?
    MacOSX user dabbling with Linux and Windows.

  8. #8
    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: QGraphicsScene/QGraphicsView performance problems

    Use the attachments feature ("Manage attachments" button below the advanced editor).

  9. #9
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default

    What would be your primary platform?

    I will have to arrange some way for you to pick up the datafiles, they will be too large for an attachment. I think I have some space at my ISP's web hotel, I will do this tomorrow.
    What will be your primary project platform?

    Here is the project. It is currently tested only for Mac, I have not built this particular project for Linux yet.
    Attached Files Attached Files
    Last edited by wysota; 6th January 2008 at 00:03. Reason: Posts merged
    MacOSX user dabbling with Linux and Windows.

  10. #10
    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: QGraphicsScene/QGraphicsView performance problems

    Quote Originally Posted by bnilsson View Post
    What would be your primary platform?
    Mine is Linux/x86.

    I will have to arrange some way for you to pick up the datafiles, they will be too large for an attachment.
    Can't you just provide some small application that would generate such example datafile? They don't have to make sense and they don't have to be larger than a megabyte. It's just a test app.

    Here is the project.
    It'd be best if you provided something small. It's easier to debug then.

    BTW. I just had a quick look at the code you provided and I have some comments:
    - I'm not sure if manipulating the update mode the way you do is a good idea, you should set the update mode once and never touch it again
    - I'm not sure if beginning by reimplementing the main drawing routine is a good idea. I'd start with the base class implementation first, it's probably trying to be smarter than your implementation
    - why do you use the data stream if you only read raw data and seek through the file? Operate on the file directly instead
    - try not to fall of the scale with your dimensions, 10nm = 10E-8, pretty close to 32bit precision.
    Last edited by wysota; 6th January 2008 at 00:18.

  11. #11
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicsScene/QGraphicsView performance problems

    Quote Originally Posted by wysota View Post
    Mine is Linux/x86.
    Were you able to build the application?
    Can't you just provide some small application that would generate such example datafile? They don't have to make sense and they don't have to be larger than a megabyte. It's just a test app.
    The example datafile supplided, "testexp_c.j51" should enable you to thest the function, but maybe not show the problem. I don't have a J51 generator ready, but I can try to make one. It would not take long, I hope.
    It'd be best if you provided something small. It's easier to debug then.
    I can strip it down further if you want. Should I?

    BTW. I just had a quick look at the code you provided and I have some comments:
    - I'm not sure if manipulating the update mode the way you do is a good idea, you should set the update mode once and never touch it again
    If I turn off update permantly it doesn't scroll. If I turn it on a large file will be drawn twice or more, taking maybe 10-30s extra before the user can zoom in to any region of interest.
    Do you have any suggestion on how to handle this?
    - I'm not sure if beginning by reimplementing the main drawing routine is a good idea. I'd start with the base class implementation first, it's probably trying to be smarter than your implementation
    I dont' quite uderstand. Please expalin.
    This is my very forst Qt application, I took the outline from a basic example (a text editor) described in the documentation. My plan was to clean it up later, and evenually make a multidocument application. But I got stuck before I got to that point.
    - why do you use the data stream if you only read raw data and seek through the file? Operate on the file directly instead
    Sure. In one of my later versions I make a linked list from the data analyzed.
    - try not to fall of the scale with your dimensions, 10nm = 10E-8, pretty close to 32bit precision.
    10-8 compared to 1 meter, yes. In the drawing unity means 1 micrometer, so the precision is no problem here.
    MacOSX user dabbling with Linux and Windows.

  12. #12
    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: QGraphicsScene/QGraphicsView performance problems

    Quote Originally Posted by bnilsson View Post
    Were you able to build the application?
    I had no data so I didn't even try.

    I can strip it down further if you want. Should I?
    You could get rid of the loading routines and just generate polygons and rectangles in the application.

    Do you have any suggestion on how to handle this?
    Yes, find out why it draws twice.

    I dont' quite uderstand. Please expalin.
    Don't reimplement anything from the scene or the view. Just you the classes provided only changing their properties and adding items to the scene.

    Edit:
    The application works just fine with the provided data. It uses about 15MB of RAM which I assume is quite fine.
    Last edited by wysota; 6th January 2008 at 12:53.

  13. #13
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsScene/QGraphicsView performance problems


Similar Threads

  1. Performance problems with overlapping qgraphicsitems
    By brjames in forum Qt Programming
    Replies: 13
    Last Post: 4th May 2008, 21:42
  2. Poor performance with Qt 4.3 and Microsoft SQL Server
    By Korgen in forum Qt Programming
    Replies: 2
    Last Post: 23rd November 2007, 10:28
  3. GraphicsView performance problems
    By Gopala Krishna in forum Qt Programming
    Replies: 79
    Last Post: 8th August 2007, 17:32
  4. Replies: 2
    Last Post: 8th March 2007, 22:22
  5. Replies: 1
    Last Post: 4th October 2006, 16:05

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.