Qt::WA_PaintOnScreen and WA_NativeWindow problem



  • I'm creating QWidget and setting

     setAttribute(Qt::WA_PaintOnScreen, true);
     setAttribute(Qt::WA_NativeWindow, true);
    

    for GPU rendering , and I'm returning nullptr into paintEngine() const;
    But sometimes I need to disable them by:

      setAttribute(Qt::WA_PaintOnScreen, false);
      setAttribute(Qt::WA_NativeWindow, false);
    

    and returning QWidget::paintengine() into paintEngine() const, instead of nullptr.
    but Qt is not drawing anything.


  • Qt Champions 2016

    @Alatriste
    Hello,
    Once your widget is native (meaning it has an OS specific handle attached to it) there is not turning back. The only way to make it non-native again is to destroy and create it anew. I don't know about the paint on screen attribute, but I'm pretty sure QWidget::paintEngine() works in a similar fashion. In the end, why would you need to do these things anyway?



  • @kshegunov Thank you for this information. It's bad that I must recreate a widget. I need this switching for some test.


  • Qt Champions 2016

    @Alatriste
    Maybe if you describe your use case, I might be able to suggest some alternative. What is exactly that you're trying to achieve?



  • @kshegunov I'm trying to render into this widget by DirectX and disabling all qt draws, but after some time I want to enable Qt draws and disable DirectX rendering. Is this information enought?


  • Qt Champions 2016

    @Alatriste
    I got that from your original question, my wondering was more to the why. Anyway. The most simple thing I can suggest is to put your DX and your Qt-drawn widget into a QStackedWidget and when you need to just switch the pages. Is this something that works for you?

    Kind regards,



  • @kshegunov Good idea but that dont works for me.. So the only way to do this, recreating widget. thanks .


  • Qt Champions 2016

    @Alatriste
    At least the only one I know of. I guess there is even the possibility to not use stacked widget at all, but have two toplevel widgets and switch them by hand, but this is pretty much what the stack widget does ...


Log in to reply
 

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