Results 1 to 20 of 24

Thread: Double Buffer

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Double Buffer

    Hi,

    Is there anyway to disable the double buffering on a QWidget?
    I'm opening a window using "QWidget::winID()" and draw on it. It seems to work when resizing the main window but it display the image once and then it paints the widget gray.

    I supose that the double buffer makes it repaint to gray.

    Thanks,
    Òscar Llarch i Galán

  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: Double Buffer

    In Qt4 you should only paint inside the paint event. If you wish to paint outside the Qt paint engine (for example with WinAPI calls), you probably need to set some attribute or pass some window flag while creating the widget, but it depends on the platform used, so you have to check it out yourself.

  3. #3
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Double Buffer

    Hi,

    For this moment I'm painting on "paintEvent".

    Thanks,
    Òscar Llarch i Galán

  4. #4
    Join Date
    Jan 2008
    Location
    Silicon valley
    Posts
    15
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Double Buffer

    Quote Originally Posted by ^NyAw^ View Post
    For this moment I'm painting on "paintEvent".
    You're probably in paintEvent() generated for another widget (like your main window). If that's correct, you could only draw in the widget which the paintEvent() was generated for, not in every widget of your application. They'll get their own paintEvents.

    The flag you're looking for (disable double buffering) seems to be Qt::WA_NoSystemBackground, but I'd strongly suggest reimplementing your widget. Instead of painting in the another widget, you could generate a pixmap - QPainter picpainter (&mypicmax), draw everything on this pixmap, and set it as the target widget label (in this case the target widget only has a single QLabel).

  5. #5
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Double Buffer

    Can you put your code of paintEvent to see the problem?
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  6. #6
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Double Buffer

    Hi,

    I cant insert my code because of it's a part of a private project.

    The window that I'm opening inside a QWidget seems to repaint itself, because it assing an image to the window and every time the image is modified I can see the new image without having to redraw it(using the private classes).

    Will take a look if there is anyway to make it works. If not, will take to use a OpenGL widget.

    Thanks,
    Òscar Llarch i Galán

  7. #7
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Double Buffer

    Quote Originally Posted by ^NyAw^ View Post
    Hi,

    I cant insert my code because of it's a part of a private project.

    The window that I'm opening inside a QWidget seems to repaint itself, because it assing an image to the window and every time the image is modified I can see the new image without having to redraw it(using the private classes).

    Will take a look if there is anyway to make it works. If not, will take to use a OpenGL widget.

    Thanks,
    Take a look of this; http://www.qtcentre.org/forum/f-qt-d...post61370.html
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  8. #8
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Double Buffer

    Will take a look if there is anyway to make it works. If not, will take to use a OpenGL widget.
    I think there is no need of it.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  9. #9
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Double Buffer

    Hi,

    Mmmm, is there anyway to disable reciving paintEvents on a QWidget? I think that if the window that I'm opening inside the widget is autorepainting(note that I don't call any draw or paint function, it autodraws the image), when it autodraw the image, QWidget calls "paintEvent" that repaints the widget to gray. This is because the bahaviour of the opened window.

    Thanks,
    Òscar Llarch i Galán

  10. #10
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Double Buffer

    You can use flags for it.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  11. #11
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Double Buffer

    Hi,

    Well, it seems to go a little.
    I disabled the own widget paintEvent and nothing happens. Then I decided to disable the main window painEvents and it works. The image is painted ok but now the problem is that the main window don't repaint itself. !!!!

    Thanks,
    Òscar Llarch i Galán

  12. #12
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Double Buffer

    Quote Originally Posted by ^NyAw^ View Post
    Hi,

    Well, it seems to go a little.
    I disabled the own widget paintEvent and nothing happens. Then I decided to disable the main window painEvents and it works. The image is painted ok but now the problem is that the main window don't repaint itself. !!!!

    Thanks,
    You have gotten the answer already. Play with flags and give some trouble to your mind. Becaue It is a enjoy of programming.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

Similar Threads

  1. Double Click Capturing
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 8th January 2011, 14:12
  2. Simple ready-to-use widget to display an image
    By sylvaticus in forum Newbie
    Replies: 6
    Last Post: 29th December 2007, 11:22
  3. QGraphicsView wont show every item
    By abbapatris in forum Qt Programming
    Replies: 7
    Last Post: 5th September 2007, 11:47
  4. Serail Port GUI
    By ShaChris23 in forum Newbie
    Replies: 17
    Last Post: 17th April 2007, 19:49
  5. MYSQL insert
    By allensr in forum Newbie
    Replies: 4
    Last Post: 14th August 2006, 16:55

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.