Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Unable to take screenshot of Qt3D window with transparent background on Mac



  • Hi,

    I have an application that renders 3d (dae) files.
    I also have a feature on my application - to take screenshots of the current scene.

    I am using Qt 5.12 on a Mac 10.14.6

    I implemented functionality so that the screenshot could be taken with a transparent
    background. This is working fine on Windows, but for some unknown reason it does not make the background transparent on Mac.

    This is the code,

    
    Qt3DRender::QRenderCaptureReply m_renderCaptureReply;
    ...
    ...
    QColor color = QColor(255, 255, 255, 0);
    if (color.isValid())
    	view->defaultFrameGraph()->setClearColor(color);
    
    m_renderCaptureReply = m_renderCapture->requestCapture();
    connect(m_renderCaptureReply, SIGNAL(completed()), this, SLOT(saveImageToFile()));
    
    
    
    void My3DQtViewer::saveImageToFile()
    {
        QImage image(m_renderCaptureReply->image().size(), QImage::Format_ARGB32);
        image.save(m_screenshotfilename, "PNG");
    }
    
    

    The image is being saved as png but with a white background.

    Any ideas what's missing?

    Thanks


  • Lifetime Qt Champion

    Hi,

    I can't answer to that directly.

    Can you provide a minimal compilable example that shows that behaviour ?