Qt Painter outside paintEvent - impossible - workaround?

前端 未结 4 1988
走了就别回头了
走了就别回头了 2020-12-22 02:27

So it appears that Qt4 doesn\'t let you draw on windows outside of a paint event. I have a lot of code that expects to be able to in order to draw rubber band lines (generi

4条回答
  •  有刺的猬
    2020-12-22 02:53

    Seems like if you could get access to the Hwnd of the window in question, you could paint on that surface. Otherwise, I'm not sure. If by pixmap method you mean something like this, I don't think it's a bad solution:

    m_composed_image = QImage(size, QImage::Format_ARGB32);
    m_composed_image.setDotsPerMeterX(dpm);
    m_composed_image.setDotsPerMeterY(dpm);
    m_composed_image.fill(Qt::transparent);
    
    //paint all image data onto new image
    QPainter painter(&m_composed_image);
    painter.drawImage(QPoint(0, 0), m_alignment_image); 
    

提交回复
热议问题