Black flicker areas resizing Direct3D11 widget in Qt 5.6



  • I am creating a GUI application with Qt 5.6 and using a custom Direct3D11 widget. I've followed the examples from the official Qt blog:
    https://blog.qt.io/blog/2016/01/28/qt-and-direct3d-12-first-encounter/
    And someone else's blog for Qt 4:
    http://blog.jholewinski.org/direct3d-11-with-qt-4/index.html

    While resizing my widget I get black areas:
    enter image description here
    This does not occur with QGraphicsView where the resize is flawless with no stretching.

    I've tried various combination of widget attributes that have not solved it:

    this->setAttribute(Qt::WA_OpaquePaintEvent, true);
    this->setAttribute(Qt::WA_PaintOnScreen, true);
    this->setAttribute(Qt::WA_DontCreateNativeAncestors, true);
    this->setAttribute(Qt::WA_NativeWindow, true);
    this->setAttribute(Qt::WA_NoSystemBackground, true);
    this->setAttribute(Qt::WA_MSWindowsUseDirect3D, true);
    this->setAutoFillBackground(false);
    

    I've also tried handling WM_ERASEBKGND:

    bool D3D11Widget::nativeEvent(const QByteArray& eventType, void *msg, long *result) {
        MSG *message = static_cast<MSG *>( msg );
    
        switch (message->message) {
        case WM_ERASEBKGND:
    	    qDebug() << "erase background\n";
    	    *result = 1L;
    	    return TRUE;
        }
    
        return QWidget::nativeEvent(eventType, message, result);
    }
    

    The only way I've managed to get rid of the flicker was to set DXGI_SCALING_STRETCH in my swap chain. However, the stretching while resizing is undesirable and does not appear in QGraphicsView. So how is it that QGraphicsView resizes without any of this flickering and how can I do the same?



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.