QVTKOpenGLNativeWidget render artefact when printing

I am trying to “print” a QVTKOpenGLNativeWidget to a pdf. To achieve this I simply use

w->render(painter);

where w is a QVTKOpenGLNativeWidget and the painter has been created using

    QPainter painter(dlg.printer());
    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.setRenderHint(QPainter::TextAntialiasing, true);

The printout itself looks fine, but I noticed two thin grey lines to the left and right of the widget. I would like to upload a sample file but seems as a new user I can’t do this.

This is not a huge issue but I still would like to get rid of these lines. Does anybody have an explanation or solution how to get rid of them?

Above screenshot has the thin grey lines to the left and right.

Do you have the artifact if you don’t enable anti-aliasing?
Does setting the background color or mode helps? (maybe what you see is the default dark background appearing due to interpolation)

Hi @lassoan,
thanks for your suggestions.
I have tried

painter.setRenderHint(QPainter::Antialiasing, false);
painter.setRenderHint(QPainter::TextAntialiasing, false);

and
painter.SetBackground(Qt::white)
renderer->SetBackground(1,1,1)

None of the above makes a difference.

I meant to change the QPainter background color or mode.

Sometimes correct behavior is only possible if the canvas size must be multiple of 2, 4, or 8. You can try to change the render window size and see if it helps.

I changed the QPainter background (see above); what do you mean by mode?

The widget has a width of 1200 so it is divisible by 8.

You can try adjusting backgroundMode and compositionMode properties.

There are also lots of parameters that you can specify for the widget’s render method - try all combinations and adjust the region size and position.

You may also try adding some more content using the painter and see if they can cover the artifacts or not (it can help determining where the root cause of the issue).

Thanks for the suggestions.
I tried all QPainter background and composition modes available; non of them make a difference. I’ll try tomorrow to add more content to see if that helps boiling down the issue.