PDA

View Full Version : Double Buffer



^NyAw^
28th January 2008, 20:04
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,

wysota
28th January 2008, 21:58
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.

^NyAw^
28th January 2008, 23:17
Hi,

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

Thanks,

seveninches
29th January 2008, 03:31
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).

ashukla
29th January 2008, 04:01
Can you put your code of paintEvent to see the problem?

^NyAw^
29th January 2008, 08:26
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,

ashukla
29th January 2008, 08:45
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-designer-3/t-promoting-qlabel-11504-post61370.html

ashukla
29th January 2008, 08:47
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.

^NyAw^
29th January 2008, 09:51
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,

ashukla
29th January 2008, 09:54
You can use flags for it.

^NyAw^
29th January 2008, 09:57
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,

ashukla
29th January 2008, 10:05
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.

^NyAw^
29th January 2008, 10:08
Hi,


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,

wysota
29th January 2008, 10:57
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.

^NyAw^
29th January 2008, 11:02
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,

^NyAw^
29th January 2008, 14:56
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.

wysota
29th January 2008, 15:07
Any details about the error?

^NyAw^
29th January 2008, 15:19
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,

wysota
29th January 2008, 15:30
Ok, but do you have OpenGL libraries linked as well?

^NyAw^
29th January 2008, 15:33
Hi,


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,

^NyAw^
29th January 2008, 15:53
Hi,

Well, I have to install OpenGL SDK. What a mistake.

My question now is:
Is there any Windows generic OpenGL libraries or have I to use my manufacturer ones? If I use my manufacturer ones, then If I want to use the application on another machine with ATI display device, there will be a problem.

Thanks,

^NyAw^
29th January 2008, 16:26
Hi,

Well, getting GLUT installed it works.

Thank you for replies.

Another question:
I'm getting images as 8 bit image without any format. Is QImage the only way to get this image to be used in the OpenGL widget?
Image Buffer -> QImage -> QPixmap -> OpenGL Texture

Is there any best way?

Thanks,

wysota
29th January 2008, 17:32
QGLWidget::convertToGLFormat()

^NyAw^
29th January 2008, 18:35
Hi,

Thanks. Now I have to learn a little OpenGL, only to show an image.

Thanks,