Results 1 to 8 of 8

Thread: update() & updateGL()

  1. #1
    Join Date
    Jun 2008
    Posts
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default update() & updateGL()

    hi.
    What I wanted to know was, is there any difference between update() and updateGL()..? i mean i tried calling both of them in my code,and both of them were executing the paintGL() function...

  2. #2
    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: update() & updateGL()

    I think update() for QGLWidget is calling updateGL() (or the other way round), so you can use either of them.

  3. #3
    Join Date
    Jun 2008
    Posts
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: update() & updateGL()

    soo... if u can call a QGLWidget with a simple update() then what's the point in having an updateGL()...??

  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: update() & updateGL()

    Qt Code:
    1. void QGLWidget::updateGL()
    2. {
    3. if (updatesEnabled())
    4. glDraw();
    5. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. void QGLWidget::paintEvent(QPaintEvent *)
    2. {
    3. if (updatesEnabled()) {
    4. glDraw();
    5. updateOverlayGL();
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 

    Do you see the difference?

  5. #5
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: update() & updateGL()

    updateGL() should be at least as fast, if not faster than update() since it bypasses the QWidget paint system with clipping, region updating and what have you.

    A quick dump of the call stack (on windows) shows that update() has the following calling order:
    Qt Code:
    1. > gltest.exe!GLWidget::paintGL() Line 18 C++
    2. QtOpenGLd4.dll!QGLWidget::glDraw() Line 3111 C++
    3. QtOpenGLd4.dll!QGLWidget::paintEvent(QPaintEvent * __formal=0x0012c354) Line 2898 C++
    4. ...
    5. QtGuid4.dll!QWidgetPrivate::drawWidget(QPaintDevice * pdev=0x0012feb8, const QRegion & rgn={...}, const QPoint & offset={...}, int flags=3) Line 1212 + 0xd bytes C++
    6. QtGuid4.dll!QWidget::repaint(const QRegion & rgn={...}) Line 1310 C++
    7. QtGuid4.dll!qt_syncBackingStore(QRegion rgn={...}, QWidget * widget=0x0012feb0, bool recursive=true) Line 250 C++
    8. QtGuid4.dll!QETWidget::translatePaintEvent(const tagMSG & msg={...}) Line 3111 + 0x2b bytes C++
    9. ...
    To copy to clipboard, switch view to plain text mode 
    whereas updateGL() gets down to business faster:
    Qt Code:
    1. > gltest.exe!GLWidget::paintGL() Line 18 C++
    2. QtOpenGLd4.dll!QGLWidget::glDraw() Line 3111 C++
    3. QtOpenGLd4.dll!QGLWidget::updateGL() Line 2768 C++
    To copy to clipboard, switch view to plain text mode 
    (I left out the Signal/Slot messaging calls in both examples)

  6. #6
    Join Date
    Jun 2008
    Posts
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default

    @ wysota
    errrr....no.... i can see an updateGL() function but no update()...!!

    @ spud

    the code didn't make that much sense to me but i think i got what it basically meant...!! thanks...
    Last edited by wysota; 23rd June 2008 at 12:40.

  7. #7
    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: update() & updateGL()

    Quote Originally Posted by rick_st3 View Post
    @ wysota
    errrr....no.... i can see an updateGL() function but no update()...!!
    update() schedules a paintEvent.

  8. #8
    Join Date
    Jun 2008
    Posts
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: update() & updateGL()

    oh..!! had completely forgotten it...!! anyways thanx mate...!!

Similar Threads

  1. QPainter update()
    By csvivek in forum Qt Programming
    Replies: 5
    Last Post: 24th March 2008, 09:42
  2. immediate update of QT object
    By db in forum Newbie
    Replies: 3
    Last Post: 14th August 2007, 12:25
  3. why there is no update on maximize? [QTableWidget]
    By macias in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2007, 15:01
  4. How to update statusbar and tooltips
    By aamer4yu in forum Qt Programming
    Replies: 9
    Last Post: 21st December 2006, 12:38
  5. QGLWidget updateGL()
    By Lele in forum Qt Programming
    Replies: 7
    Last Post: 30th May 2006, 15:08

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.