Page 1 of 2 12 LastLast
Results 1 to 20 of 24

Thread: Double Buffer

  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!

  13. #13
    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,

    Quote Originally Posted by ashukla View Post
    Play with flags and give some trouble to your mind.
    Oh yes, I have to play Brain Training a little more. XD

    Will tell you if I make it work.

    Thanks,
    Òscar Llarch i Galán

  14. #14
    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

    But why do you want to disable the paint event? Paint what you want to display on a pixmap and in the paint event simply paint the pixmap on the widget.

  15. #15
    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,

    Paint what you want to display on a pixmap and in the paint event simply paint the pixmap on the widget.
    I'm trying to use 20 widgets that have to display 25 images per second. I think that OpenGL will be the best selection, so I will only have to take the image from the buffer, convert it to pixmap and bind to a OpenGL texture(I'm novice on OpenGL use).

    Thanks,
    Òscar Llarch i Galán

  16. #16
    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'm having linking errors using OpenGL calls inside my code.

    I'm using Visual Studio .NET 2003 and Qt 4.3

    I included the QtOpenGL module.
    Òscar Llarch i Galán

  17. #17
    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

    Any details about the error?

  18. #18
    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

    LPR error LNK2019: sÃ*mbolo externo __imp__glMatrixMode@4 sin resolver al que se hace referencia en la función "public: virtual void __thiscall QMatroxGLWidget::initializeGL(void)" (?initializeGL@QMatroxGLWidget@@UAEXXZ)

    I get similar link errors for every OpenGL call that I'm using.
    I have the "QtOpenGLd4.lib" on linker options.

    Thanks,
    Òscar Llarch i Galán

  19. #19
    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

    Ok, but do you have OpenGL libraries linked as well?

  20. #20
    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,

    Quote Originally Posted by wysota View Post
    Ok, but do you have OpenGL libraries linked as well?
    Really don't know. How can I know it and how to do it?

    Thanks,
    Òscar Llarch i Galán

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.