Is there a way to access the image on the QWidget's backing store?

前端 未结 1 1427
旧巷少年郎
旧巷少年郎 2020-12-02 01:23

I\'m doing some compositing inside the paintEvent() in a custom widget. Some of the compositing is done when some areas are already painted, and I need access t

相关标签:
1条回答
  • 2020-12-02 01:48

    It is possible, but it is not portable. The QBackingStore is just a wrapper class around a QImage buffer on most platforms, but I suppose this is not guaranteed. I've researched this issue when writing the QuickWidget. A cast is needed:

    QImage * image = dynamic_cast<QImage*>(backingStore()->paintDevice());
    if (image != 0) // it's an image, do something with it
    

    Be careful though not to cause the QImage to detach. Things such as resizing are off limits.

    Check the QuickWidget out at:

    https://code.google.com/p/quickwidget/

    0 讨论(0)
提交回复
热议问题