PDA

View Full Version : QWidget::render with DrawChildren flag



Apocalypse
3rd January 2009, 11:51
Hi! I try to render widget's children into pixmap. Code:


//QWidget this;QPixmap wpix
wpix=QPixmap(this->size());
wpix.fill(Qt::transparent);
this->render(&wpix,QPoint(0,0),QRect(0,0,640,1024), DrawChildren);

But in pixmap I get rendered widget's children and widget itself. Even with DrawWindowBackround flag. What could be wrong?

Apocalypse
3rd January 2009, 13:45
I got closer to the answer, but i don't think it's normal.
I create widget and use it as main window. Then I created widget neccessary for me as children of that window. Rendering children widget give me a result. So what is the problem? Bug?

wysota
3rd January 2009, 15:49
What exactly do you want to achieve? To render only the children of some widget? This is not possible directly - render() renders the widget and optionally its children. You can put the children on a simple QWidget that is transparent and render that. What you do with the main window it's probably that you render the central widget that is transparent so you don't see it but only its children.

Apocalypse
4th January 2009, 17:45
i want to render only children of some widget without background. But it didn't work with window itself. I have success only when widget, which I want to render, was directed inside of window.

wysota
4th January 2009, 22:15
That's natural as top level windows have an obligatory background while child widgets don't. Therefore rendering a non-window widget that is itself transparent will only make its children visible (note that the widget itself gets rendered, it just doesn't paint any pixels - if you change the value of one specific property of the widget (find out which yourself), you'll get a background instead of transparency).