Qt: How to force a hidden widget to calculate its layout?

前端 未结 6 744
北海茫月
北海茫月 2020-12-09 17:01

What I am trying to do is render a qwidget onto a different window (manually using a QPainter)

I have a QWidget (w) with a layout and a bunch of child controls. w i

6条回答
  •  感情败类
    2020-12-09 17:56

    Forcing a layout calculation on a widget without showing it on the screen:

    widget->setAttribute(Qt::WA_DontShowOnScreen);
    widget->show();
    

    The show() call will force the layout calculation, and Qt::WA_DontShowOnScreen ensures that the widget is not explicitly shown.

提交回复
热议问题