Results 1 to 5 of 5

Thread: QWidget::render with DrawChildren flag

  1. #1
    Join Date
    Mar 2008
    Location
    Ukraine, Donetsk
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QWidget::render with DrawChildren flag

    Hi! I try to render widget's children into pixmap. Code:

    Qt Code:
    1. //QWidget this;QPixmap wpix
    2. wpix=QPixmap(this->size());
    3. wpix.fill(Qt::transparent);
    4. this->render(&wpix,QPoint(0,0),QRect(0,0,640,1024), DrawChildren);
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    Mar 2008
    Location
    Ukraine, Donetsk
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QWidget::render with DrawChildren flag

    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?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QWidget::render with DrawChildren flag

    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.

  4. #4
    Join Date
    Mar 2008
    Location
    Ukraine, Donetsk
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QWidget::render with DrawChildren flag

    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.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QWidget::render with DrawChildren flag

    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).

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.