occ disables transparency of Qt widgets

Hi,

I want to create some OSD like display. For testing purpose I extended a Qt sample (hellogl2) which worked ootb.
Trying to achieve the same with occ failed. Occ turned Qt transparent background into fully opaque.
I tried to add Qt::WA_NativeWindow but that did not change anything.

Is it possible, to initialize opengl driver like Qt does and so enable transparency in Qt overlays?

Kirill Gavrilov's picture

Which particular Qt sample you are referring to?

I would guess that you are using QOpenGLWidget sample, which implement a completely different approach for integrating OpenGL renderer to widgets compared to QGLWidget.

In that case you may try another OCCT sample.

DjangoReinhard's picture

No, I used OCCTOverview as blueprint, which uses QWidget only. Gonna change to your new sample.

Thank you very much for that enriched example. I learned a lot just by reading your comments! Thank you. That's quite sophisticated stuff. Never could have find out that on my own. Thanks for sharing your skills!

Just a note about your qmake pro-file: I'm not that used to qmake - just a beginner. Both files (pro and template) look quite complicated to adopt. I use occ from git repo, compiled with qtcreator (without installing it) and in pro-file I just use:

INCLUDEPATH += \
   ... \
    /usr/local/src/build-occt-Desktop_5_15_opt-Debug/include/opencascade

and

LIBS += -L/usr/local/src/build-occt-Desktop_5_15_opt-Debug/lin64/gcc/libd

to specify used location of occ. It worked fine for your sample too.

Kirill Gavrilov's picture

No, I used OCCTOverview as blueprint, which uses QWidget only.

While asking I was referring to your screenshot of a (non-OCCT) Qt sample. As I'm not much familiar with samples coming with Qt SDK, I was asking what this sample used QOpenGlWidget or QGLWidget just to confirm my guess.

Both files (pro and template) look quite complicated to adopt

What exactly looks complicated there? custom.pri just adds the same paths to INCLUDEPATH / LIBS, just trying to do this stuff in a cross-platform way.

DjangoReinhard's picture

While asking I was referring to your screenshot of a (non-OCCT) Qt sample.

Oups, got you wrong!

That non-OCCT sample is a Qt example at examples/opengl/hellogl2 and the GLWidget is declared like this:

class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
   ...
};

What exactly looks complicated there?

Well, although well formatted - when it failed, I was already nerved by the many bugs I created. Too many curly brackets and Dollars over Dollars ;)

Now being in a relaxed state, I could google for printing of qmake variables and so could check the assembled paths. On my system (debian 11) platform should be lin64 instead of lin

So its not complicated - just my simpleminded habbit: in case of error I go back to what I know.

Kirill Gavrilov's picture

So its not complicated - just my simpleminded habbit: in case of error I go back to what I know.

Got it - just something non-trivial to user never working with qmake project files before ;). Just looking for ideas if something could be improved. I've thought that about adding CMake project files in addition to qmake, but don't know if they would be any better for a sample (but at least one would see errors in cmake-gui).