Results 1 to 12 of 12

Thread: QGraphicsView Frame Rate

  1. #1
    Join Date
    Jul 2009
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default QGraphicsView Frame Rate

    Hi ,

    Anybody know what is the current frame rate of QGraphicsView? And is it possible to adjust manually?

    Thanks for any advise.

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

    Default Re: QGraphicsView Frame Rate

    QGraphicsView does not have a frame rate.
    Are you talking about animations? In that case, it depends on how you're doing the animation and you need to provide more details.

  3. #3
    Join Date
    Jul 2009
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QGraphicsView Frame Rate

    yes , I mean animation.

    I am trying to make an animation that move a list of pixmap from left to right. I didn't use State machine. I just make a list of QPropertyAnimation and set the start and end value.

    However, the animation is a little bit choppy when it is run in full screen mode. Seem that it is out-sync-ed with screen refresh rate. Therefore I would like to adjust the frame rate / animation update rate.

  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: QGraphicsView Frame Rate

    If it's choppy then it means GraphicsView can't deal with that much information to process. You need to optimize some things by different ways described all over this forum (and not only here).
    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 2009
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QGraphicsView Frame Rate

    Thanks. But I find that even I move a single rectangle on QGraphicsView, it is slightly choppy... Anyway , I will check the old post first.

  6. #6
    Join Date
    Jul 2009
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QGraphicsView Frame Rate

    If I understand correctly (correct me if I am wrong) , in order to assign a specific update rate to view , it should :

    1) Set QGraphicsView update module to NoViewportUpdate
    2) Connect a timer's timeout signal to QGraphicsScene::update() slot

    However, I have a question about the above behaviour. I think QGraphicsScene::update() would update every items on scene , no matter the region/rect is changed or not. Am I correct? Is it possible to update only the changed region/rect like what BoundingRectViewportUpdate mode do?

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

    Default Re: QGraphicsView Frame Rate

    It shouldn't normally be choppy. However, many things can affect painting speed. If you're on linux you might want to enable the raster or opengl paint systems for more speed. If this is on windows you are almost certainly doing something wrong, since it should be plenty fast enough. Post more code for more help.

  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: QGraphicsView Frame Rate

    Quote Originally Posted by benlau View Post
    If I understand correctly (correct me if I am wrong) , in order to assign a specific update rate to view , it should :

    1) Set QGraphicsView update module to NoViewportUpdate
    2) Connect a timer's timeout signal to QGraphicsScene::update() slot
    Not if you are using the Animation Framework. The framework runs its own timer. You can check the exact frequency in the sources but I wouldn't be surprised if it was dynamically calculated.
    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.


  9. #9
    Join Date
    Jul 2009
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QGraphicsView Frame Rate

    Quote Originally Posted by pherthyl View Post
    It shouldn't normally be choppy. However, many things can affect painting speed. If you're on linux you might want to enable the raster or opengl paint systems for more speed. If this is on windows you are almost certainly doing something wrong, since it should be plenty fast enough. Post more code for more help.
    Thanks.

    hmm... I think I should call it flickering instead of choppy. I made a very simple program with only a big red rectangle moving around the screen. With the options of -graphicssystem raster / opengl. It will look better. But still have a slightly fickering or tearing depend on system.

    Linux:
    - raster : flickering
    - opengl: segfault (seem to be driver issue. )

    Mac:
    - raster : flickering
    - opengl : tearing


    The code
    Qt Code:
    1. #include <QtGui>
    2.  
    3. class Rect : public QObject , public QGraphicsRectItem {
    4. Q_OBJECT
    5.  
    6. public:
    7. Q_PROPERTY(QPointF pos WRITE setPos READ pos)
    8.  
    9. Rect(QGraphicsItem* item = 0) : QObject(),QGraphicsRectItem(item) {
    10. }
    11. };
    12.  
    13. int main(int argc , char **argv){
    14. QApplication app(argc,argv);
    15.  
    16. view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
    17. view.setCacheMode(QGraphicsView::CacheBackground);
    18. view.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
    19.  
    20.  
    21. view.setScene(&scene);
    22. scene.setSceneRect(0,0,1280,1024);
    23.  
    24. Rect* rect = new Rect();
    25. rect->setRect(0,0,500,500);
    26. scene.addItem(rect);
    27.  
    28. QBrush brush(Qt::red);
    29. rect->setBrush(brush);
    30. rect->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
    31.  
    32. QPropertyAnimation anim(rect,"pos");
    33. int duration = 5000;
    34.  
    35. anim.setStartValue(QPointF(0,0));
    36. anim.setKeyValueAt(0.25 , QPointF(500,0) );
    37. anim.setKeyValueAt(0.5 , QPointF(500,500) );
    38. anim.setKeyValueAt(0.75 , QPointF(0,500) );
    39. anim.setEndValue(QPointF(0,0));
    40. anim.setDuration(duration);
    41. anim.setLoopCount(-1);
    42.  
    43. anim.start();
    44.  
    45. view.show();
    46.  
    47.  
    48. return app.exec();
    49. }
    50.  
    51. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files
    Last edited by benlau; 7th April 2010 at 11:09. Reason: added attachment

  10. #10
    Join Date
    Jul 2009
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QGraphicsView Frame Rate

    Quote Originally Posted by wysota View Post
    Not if you are using the Animation Framework. The framework runs its own timer. You can check the exact frequency in the sources but I wouldn't be surprised if it was dynamically calculated.
    Thanks.

    Becasue I may run the program on an embedded hardware, I am trying to avoid it did too much refresh that consume too much cpu power.

  11. #11
    Join Date
    Oct 2010
    Posts
    2

    Default Re: QGraphicsView Frame Rate

    Hi benlau,

    I have the same problem, my code is very similar and same render hints,
    have you resolved? how?

    thank you

  12. #12
    Join Date
    Jul 2009
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QGraphicsView Frame Rate

    Hi themk,

    I still can't find a prefect solution , the only way I could try is to avoid a big rectangle moving in a constant speed.

    p.s I have patched Qt and allow it to set animation fps by environment variable.

Similar Threads

  1. Retrieval of frame rate in Phonon.
    By Theo Adams in forum Qt Programming
    Replies: 2
    Last Post: 6th July 2010, 19:00
  2. OpenGL frame rate
    By martinb0820 in forum Installation and Deployment
    Replies: 3
    Last Post: 2nd October 2009, 19:24
  3. OpenGL frame rate under 64-bit XP
    By martinb0820 in forum Qt Programming
    Replies: 1
    Last Post: 2nd October 2009, 19:23
  4. Frame rate problem
    By MrShahi in forum Qt Programming
    Replies: 1
    Last Post: 30th July 2008, 23:06
  5. Change frame rate
    By superutsav in forum General Programming
    Replies: 1
    Last Post: 3rd August 2006, 21:02

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.