PreviewLabel Class Reference

#include <previewlabel.h>

Inheritance diagram for PreviewLabel:

Inheritance graph
[legend]
Collaboration diagram for PreviewLabel:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition at line 33 of file previewlabel.h.

Public Member Functions

 PreviewLabel (QWidget *parent=0)
void setPixmap (const QPixmap &pixmap)

Protected Member Functions

void paintEvent (QPaintEvent *event)

Private Attributes

QPixmap pixmap


Constructor & Destructor Documentation

PreviewLabel::PreviewLabel ( QWidget parent = 0  ) 

Definition at line 27 of file previewlabel.cpp.

00028     : QWidget(parent)
00029 {
00030 }


Member Function Documentation

void PreviewLabel::setPixmap ( const QPixmap pixmap  ) 

Definition at line 41 of file previewlabel.cpp.

References pixmap.

Referenced by PreviewDialog::on_pageList_currentItemChanged().

00042 {
00043     this->pixmap = pixmap;
00044 }

void PreviewLabel::paintEvent ( QPaintEvent event  )  [protected, virtual]

This event handler can be reimplemented in a subclass to receive paint events which are passed in the event parameter.

A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint() or update(), or because the widget was obscured and has now been uncovered, or for many other reasons.

Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QTableView do this, for example.

Qt also tries to speed up painting by merging multiple paint events into one. When update() is called several times or the window system sends several paint events, Qt merges these events into one event with a larger region (see QRegion::united()). repaint() does not permit this optimization, so we suggest using update() whenever possible.

When the paint event occurs, the update region has normally been erased, so that you're painting on the widget's background.

The background can be set using setBackgroundRole() and setPalette().

From Qt 4.0, QWidget automatically double-buffers its painting, so there's no need to write double-buffering code in paintEvent() to avoid flicker.

Note: Under X11 it is possible to toggle the global double buffering by calling qt_x11_set_global_double_buffer(). Example usage:

See also:
event(), repaint(), update(), QPainter, QPixmap, QPaintEvent, {Analog Clock Example}

Reimplemented from QWidget.

Definition at line 32 of file previewlabel.cpp.

References QPainter::begin(), QPainter::drawPixmap(), QPainter::end(), QWidget::event(), QPainter::fillRect(), and pixmap.

00033 {
00034     QPainter painter;
00035     painter.begin(this);
00036     painter.fillRect(event->rect(), QColor(224,224,224));
00037     painter.drawPixmap(0, 0, pixmap);
00038     painter.end();
00039 }

Here is the call graph for this function:


Member Data Documentation

QPixmap PreviewLabel::pixmap [private]

Definition at line 45 of file previewlabel.h.

Referenced by paintEvent(), and setPixmap().


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 15:36:32 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1