Qwidget Six refresh functions (there are qwidget::erase functions and do not produce paint events)

Source: Internet
Author: User

A Take a look at several methods and properties:

1. Qwidget * Qscrollview::viewport () const

2. void Qwidget::p aintevent (qpaintevent *) [Virtual protection]

3. void Qwidget::repaint (int x, int y, int w, int h, bool erase = TRUE) [slot]

4. void Qwidget::update () [Groove]

5. void qwidget::erase (int x, int y, int w, int h)

6. BOOL Updatesenabled

Two Now in detail:

1. Qwidget * Qscrollview::viewport () const

Returns the viewport widget in the scrolling view, which contains the content window part or the area to be drawn.

2. void Qwidget::p aintevent (qpaintevent *) [Virtual protection]

Called whenever the widget needs to be redrawn. Each window part to display the output must implement it. This event handler can be re-implemented in the subclass to receive the paint event. It can be the result of repaint () or update (). Many widgets are simply redrawing the entire interface when they are requested, but some widgets are optimized by simply drawing the requested area qpaintevent::region (), for example, Qlistview and Qcanvas.

Qt can also speed up drawing by merging multiple drawing events into one. When update () is called several times or the window system sends several draw events, Qt merges them into a larger area (refer to Qregion::unite ()) for an event. Repaint () does not allow this optimization, so whenever possible we try to use Update ().

When a drawing event occurs, the update area is usually erased. There are some exceptions, and you can tell whether the widget is erased by qpaintevent::erased ().

3. void Qwidget::repaint (int x, int y, int w, int h, bool erase = TRUE) [slot]

by calling PaintEvent () immediately to redraw the widget directly, if erase is true, QT erases the area (x,y,w,h) before the PaintEvent () call. If W is a negative number, it is replaced by the width ()-X, and if H is a negative number, it is replaced by the height ()-Y. If you need to redraw immediately, it is recommended to use repaint (), for example during animation. In most cases, update () is better because it allows QT to optimize speed and prevent flicker. Warning: If you call repaint () in a function and it is called by PaintEvent () yourself, you may see a wireless loop. The update () function never generates a loop.

4. void Qwidget::update () [Groove]

Updates the widgets and when QT returns to the main event, it plans the drawing events to be processed. This allows QT to be optimized for faster speeds and fewer flashes than calls to repaint (). The result of several calls to update () is usually just one paintevent () call. Qt usually erases the area of the widget before the PaintEvent () call, only if the Wrepaintnoerase widget is set.

5. void qwidget::erase (int x, int y, int w, int h)

Erasing the specified area (x, Y, W, h) in the widget does not produce a paint event.

If w is negative, it is replaced by width ()-X. If H is negative, it is replaced by height ()-Y.

The child window part is not affected.

6. BOOL Updatesenabled

This property holds whether the update is in effect.

If the update fails, calling Update () and repaint () is not effective. If the update fails, drawing events from the window System are handled normally. Setupdatesenabled () is often used to invalidate updates within a short period of time, for example to avoid screen flicker during large changes.

Instance:

Setupdatesenabled (FALSE);

Bigvisualchanges ();

Setupdatesenabled (TRUE);

Repaint ();

Set the property value by Setupdatesenabled () and get the property value through Isupdatesenabled ().

Qwidget Six Refresh functions (there is an qwidget::erase function and does not produce a drawing event)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.