1. 程式人生 > >在Qt 4.4中,Alien Widget誕生了(Window負責與窗口系統的聯系。Alien被號稱是所有閃爍的終結者)

在Qt 4.4中,Alien Widget誕生了(Window負責與窗口系統的聯系。Alien被號稱是所有閃爍的終結者)

http rect popu hang 重繪 das data- target native

2011年09月29日 23:47:46 閱讀數:7269

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了,...

參考

  • http://labs.qt.nokia.com/2011/04/01/qt-hidden-gems/

  • http://labs.qt.nokia.com/2009/02/13/bnilsenflush/

  • http://labs.qt.nokia.com/2009/12/16/qt-graphics-and-performance-an-overview/

  • http://labs.qt.nokia.com/2008/02/04/qt-44-and-painting-performance/

  • http://labs.qt.nokia.com/2008/05/12/qwidget-vs-graphics-view-ding-ding-ding

  • http://labs.qt.nokia.com/2007/08/09/qt-invaded-by-aliens-the-end-of-all-flicker/

  • http://www.cuteqt.com/blog/?p=340

https://blog.csdn.net/dbzhang800/article/details/6835722

在Qt 4.4中,Alien Widget誕生了(Window負責與窗口系統的聯系。Alien被號稱是所有閃爍的終結者)