• 9914阅读
  • 2回复

有关QWidget::render() [复制链接]

上一主题 下一主题
离线vvgzjj
 
只看楼主 正序阅读 楼主  发表于: 2009-01-15
— 本帖被 XChinux 执行加亮操作(2009-01-18) —
各位老大,文档中对QWidget::redner(QPaintDevice* target, ....)的解释是将target 渲染到当前的QWidget上,可是在QT提供的例子中,有这样一段代码(在一个QWidget中):
        QPixmap pixmap1(size());
                  render(&pixmap);
最终结果好象是将当前QWidget的pixmap渲染了pixmap1。不知具体是怎么回事
离线water_wf

只看该作者 2楼 发表于: 2009-01-15
文档中对QWidget::redner(QPaintDevice* target, ....)的解释是将target 渲染到当前的QWidget上?
仔细理解target的含义
离线sanghk

只看该作者 1楼 发表于: 2009-01-15
你看错了
void QWidget::render ( QPaintDevice * target, const QPoint & targetOffset = QPoint(), const QRegion & sourceRegion = QRegion(), RenderFlags renderFlags = RenderFlags( DrawWindowBackground | DrawChildren ) )
Renders the sourceRegion of this widget into the target using renderFlags to determine how to render. Rendering starts at targetOffset in the target. For example:
QPixmap pixmap(widget->size());
widget->render(&pixmap);If sourceRegion is a null region, this function will use QWidget::rect() as the region, i.e. the entire widget.

Note: Make sure to call QPainter::end() for the given target's active painter (if any) before rendering. For example:

QPainter painter(this);
...
painter.end();
myWidget->render(this);This function was introduced in Qt 4.3.
快速回复
限100 字节
 
上一个 下一个