Usage of AIS V3d_Viewer with Qt (Qt5) on windows. Viewer is blinking.

Hello, Everyone.

I cannot find any information how to solve the following problem:

I've built the example of using AIS with Qt . It is done similar to what is given in ros/samples, but even simpler - Widget is taken from CommonViewer class - this is the main thing. It is created just as central widget in the main window.

I can build and start the example just fine, but the problem is that the viewer is blinking when I reside the window and even worse - it may stay gray (or partly gray).

I checked, that I set

setAttribute(Qt::WA_PaintOnScreen);
setAttribute(Qt::WA_NoSystemBackground);

(actually even twice - as it is done twice in the example) during the creation of the viewer widget, but this does not help.

I guess, that this is some standard thing, but I cannot figure out how to solve this. Any hints are highly appreciated.

I work with OCCT660 and Qt 5.1

Thanks in advance.

Dmitrii Semikin's picture

I've just noticed, that I did not mention: I work on windows.

Dmitry Kidyaev's picture

1. Use QWidget as the parent instead of QGLWidget.
use QWidget(parent, Qt::MSWindowsOwnDC) in Qt 5.1 - it is very important.
Otherwise paint event does not occur.
2. Set the subset of the following parameters in the constructor:
setMouseTracking(true);
setBackgroundRole(QPalette::NoRole);
setFocusPolicy(Qt::StrongFocus);
setAttribute(Qt::WA_PaintOnScreen);
setAttribute(Qt::WA_NoSystemBackground);
setAutoFillBackground(false);
3. implement function
QPaintEngine *OCCWidget::paintEngine() const
{
return NULL;
}

Dmitrii Semikin's picture

Hello, Dmitry,

Lots of thanks. This works perfectly.

In more details:

1. => I've already done it this way except for Qt::MSWindowOwnDC flag.
2. => I've already done it this way except for the latest setAutoFillBackground(false)
3. ==>> This was the actual point. When I implemented this function, the blinking has gone and the viewer started to paint itself normally even without code changes related to previous two points (see above).

Possibly, this should be introduced into the samples in newer OCCT versions or into the documentation/wiki/FAQ if there is some.

Thanks once again.

Dmitry Kidyaev's picture

Seems No.1 depends on OCC build and/or hardware/driver details.
My OCC (6.6.0) samples for the Qt includes No 3. in the basic viewr class.

/*!
Get paint engine for the OpenGL viewer. [ virtual public ]
*/
QPaintEngine* View::paintEngine() const
{
return 0;
}

Dmitrii Semikin's picture

Hello, Dmitry,

I'm sorry. You are right, indeed in both examples containing implementation of the viewer (common and voxel demo), viewer have this method. So, this is only my lack of attention, which is the source of my problem.

Thanks once again.