返回介绍

QDirectPainter Class

发布于 2019-10-04 14:59:26 字数 5730 浏览 1003 评论 0 收藏 0

The QDirectPainter class provides direct access to the video hardware. More...

#include <qdirectpainter_qws.h>

Inherits QPainter.

List of all member functions.

Public Members

  • QDirectPainter ( constQWidget*w )
  • ~QDirectPainter ()
  • uchar * frameBuffer ()
  • int lineStep ()
  • int transformOrientation ()
  • int numRects () const
  • const QRect & rect ( inti ) const
  • QRegion region ()
  • int depth () const
  • int width () const
  • int height () const
  • int xOffset () const
  • int yOffset () const
  • QPoint offset () const
  • QSize size () const
  • void setAreaChanged ( constQRect&r )

Detailed Description

The QDirectPainter class provides direct access to the video hardware.

Only available in Qt/Embedded.

When the hardware is known and well defined, as is often the case with software for embedded devices, it may be useful to manipulate the underlying video hardware directly. In order to do this in a way that is co-operative with other applications, you must lock the video hardware for exclusive use for a small time while you write to it, and you must know the clipping region which is allocated to a widget.

QDirectPainter provides this functionality.

In the simplest case, you make a QDirectPainter on a widget and then, observing the clip region, perform some platform-specific operation. For example:

        void MyWidget::updatePlatformGraphics()
        {
            QDirectPainter dp( this );
            for ( int i = 0; i < dp.numRects; i++ ) {
                const QRect& clip = dp.rect(i);
                ... // platform specific operation
            }
        }
    

The platform-specific code has access to the display, but should only modify graphics in the rectangles specified by numRects() and rect(). Note that these rectangles are relative to the entire display.

The offset() function returns the position of the widget relative to the entire display, allowing you to offset platform-specific operations appropriately. The xOffset() and yOffset() functions merely return the component values of offset().

For simple frame-buffer hardware, the frameBuffer(), lineStep(), and depth() functions provide basic access, though some hardware configurations are insufficiently specified by such simple parameters.

Note that while a QDirectPainter exists, the entire Qt/Embedded window system is locked from use by other applications. Always construct the QDirectPainter as an auto (stack) variable, and be very careful to write robust and stable code within its scope.

See also Graphics Classes.


Member Function Documentation

QDirectPainter::QDirectPainter ( constQWidget*w )

Construct a direct painter on w. The display is locked and the mouse cursor is hidden if it is above w.

QDirectPainter::~QDirectPainter ()

Destroys the direct painter. The mouse cursor is revealed if necessary and the display is unlocked.

int QDirectPainter::depth () const

Returns the bit-depth of the display.

uchar * QDirectPainter::frameBuffer ()

Returns a pointer to the framebuffer memory if available.

int QDirectPainter::height () const

Returns the height of the widget drawn upon.

int QDirectPainter::lineStep ()

Returns the spacing in bytes from one framebuffer line to the next.

int QDirectPainter::numRects () const

Returns the number of rectangles in the clip region.

See also rect() and clipRegion().

QPoint QDirectPainter::offset () const

Returns the position of the widget relative to the entire display.

constQRect& QDirectPainter::rect ( inti ) const

Returns a reference to rectangle i of the clip region. Valid values for i are 0..numRects()-1.

See also clipRegion().

void QDirectPainter::setAreaChanged ( constQRect&r )

Sets the area changed by the transaction to r. By default, the entire widget is assumed to have changed. The area changed is only used by some graphics drivers, so often calling this function for a smaller area will make no difference.

QSize QDirectPainter::size () const

Returns the size of the widget drawn upon.

See also width() and height().

int QDirectPainter::transformOrientation ()

Returns a number that signifies the orientation of the framebuffer.
0no rotation
190 degrees rotation
2180 degrees rotation
3270 degrees rotation

int QDirectPainter::width () const

Returns the width of the widget drawn upon.

int QDirectPainter::xOffset () const

Returns the X-position of the widget relative to the entire display.

int QDirectPainter::yOffset () const

Returns the Y-position of the widget relative to the entire display.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文