Is it possible to set the background color of a glWidget? If I use a command such as glClearColor(...) then the whole widget takes that color even though the actual viewport of the openGL might not be covering the whole widget.
Is it possible to set the background color of a glWidget? If I use a command such as glClearColor(...) then the whole widget takes that color even though the actual viewport of the openGL might not be covering the whole widget.
What do you mean it might not be covering the whole widget?
Well with a code like this for example:
double side = std::min(width / ratio, height);
glViewport(int(width - side*ratio) / 2, int(height - side) / 2, int(side*ratio), int(side));
where width and height is the widgets extents, I would get an image thats always a certain ratio 4:3 or 16:9 for example.
Ok, but the rest is still occupied by the gl context, so you have to use OpenGL means to change the background color. I think glClear() should clear everything, not only the GL viewport. If I'm mistaken and you are talking about something else, then try using QPalette and changing the background role colour.
Bookmarks