QWidget 之paint部分杂记

13 篇文章 5 订阅

Qt 4.0

automatically double-buffers

Qt 4.1

QWidget::autoFillBackground

Qt 4.2

delayed widget creation (DWC)

stylesheet

Qt 4.3

QWidget::render

Qt 4.4

Alien Widget

Qt 4.5

Translucent Windows

Qt 4.6

widget's graphics effect

Qt 4.8

lighthouse (qpa)

Qt4.0

  • 在Qt 4.0中,启用双缓冲,不必在paintEvent()中编写双缓冲代码来避免闪烁。

Qt4.1

  • 在Qt 4.1中,通过启用背景自动传递(propagation),widget不再有任何默认的背景。引入backingstore这个东西。



Qt4.2

  • 在Qt 4.2中,延时控件创建(delayed widget creation)的引入,使得widget可以在没有真实窗口句柄的情况下被创建。

QWindowSurface 与 QWidgetBackingStore

Even though QWidget is a QPaintDevice subclass, one will never render directly into a QWidget’s surface. Instead, during the paintEvent, the painting is redirected to an offscreen surface which is represented by the internal class QWindowSurface.

QWidgetBackingStore is responsible for figuring out which parts of the window surface needs to be updated prior to showing it to screen, so its really a repaint manager.

When the concept of backingstore was introduced in Qt 4.1, the two classes were the same, but the introduction of more varying ways to get content to screen made us split it in two.

Qt4.4

  • 在Qt 4.4中,Alien Widget诞生了,这样一来,Window和Widget尽管仍是同一个类,却是不同的东西。Window负责与窗口系统的联系。Alien被号称是所有闪烁的终结者,见Qt Invaded By Aliens — The End of All Flicker

Qt::WA_NativeWindow

创建原生窗体,即带句柄

Qt::WA_PaintOnScreen

强制创建原生窗体

Qt::Window

顶级窗口,必须是原生窗体 (?)

QGLWidget

必须是原生窗体

如果一个widget已经是alien Widget,如果对其设置上述标志,或者对其调用winId()函数,都会导致其重新创建为一个native widget。

Qt4.5

  • 在Qt 4.5中,graphics system的概念被引入(比如选项有:raster|opengl|x11|native 等)。引人了一个Qt::WA_TranslucentBackground 属性,这个东西和QWidget::setWindowOpacity()有些比较容易混哈。

QWidget::setWindowOpacity()函数,设置窗体(即:isWindow()为真的widget)的整体不透明度, 从0.0到1.0之间, 值越大越不透明。

Qt::WA_TranslucentBackground,这个属性每个QWidget都可以单独设置。不被绘制的区域(背景)都是透明的,绘制的区域的透明程度通过颜色或图片的Alpha Channel值来控制。

Qt4.6

  • 在Qt 4.6中,graphics effect被引入。但是,现在,已经不建议使用:

Graphics Effects
State: Deprecated
Reasoning: flawed design, we don’t recommend taking maintainership of this code.

QGraphicsEffect 的子类需要重新实现draw()函数。

以安装了QGraphicsOpacityEffect了QWidget为例,当每次需要重绘时,QWidgetPrivate::drawWidget()不是发送QPaintEvent事件,以调用我们的paintEvent()函数;而是调用QGraphicsOpacityEffect的draw()函数,该函数内,通过QWidget::render()调用paintEvent()将内容绘制在一个QPixmap中,而后设置QPainter的不透明度,绘制QPixmap到目标。

Qt4.8

  • 在Qt 4.8中,正式引入lighthouse了,...

参考


  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值