QT之QDirectPainter使用
来源:互联网 发布:白金数据 电影天堂 编辑:程序博客网 时间:2024/06/05 10:09
为了在嵌入式上解决界面刷新闪烁问题,QT提出了两种解决方案:
1、对控件设置Qt::WA_PaintOnScreen
Indicates that the widget wants to draw directly onto the screen. Widgets with this attribute set do not participate in composition management, i.e. they cannot be semi-transparent or shine through semi-transparent overlapping widgets. Note: This flag is only supported on X11 and it disables double buffering. On Qt for Embedded Linux, the flag only works when set on a top-level widget and it relies on support from the active screen driver. This flag is set or cleared by the widget's author. To render outside of Qt's paint system, e.g., if you require native painting primitives, you need to reimplement QWidget::paintEngine() to return 0 and set this flag.
2、使用QDirectPainter直接在Framebuffer上绘图
QDirectPainter支持3种模式,一般我们使用NonReserved即可:
QDirectPainter mPainter(this)
QDirectPainter::lock();
mPainter.setRegion(requsteRegion);
QRegion allocatedregion=mPainter.allocatedRegion();
mPainter.startPainting();
//结合allocatedregion在QDirectPainter::framebuffer()指向的缓存中直接绘图。
mPainter.endPainting();
QDirectPainter::unlock();
需要注意allocatedRegion返回值
QRegion QDirectPainter::allocatedRegion () const
Returns the currently reserved region.
Note that if the QDirectPainter::Reserved flag is set, the region returned by this function will always be equivalent to the region returned by the requestedRegion() function. Otherwise they might differ (see Dynamic Allocation for details).
对于LCD分辨率640*480的显示器来说,居中有一个大小为100*100的window,当setRegion一般传入640*480后,allcatedRegion会返回一个QRegion,这个QRegion包括4个Rect,用于表明除中间100*100外的LCD其他区域。 (前提条件是window必须有focus)
在项目的应用中,我需要一个窗口显示摄像头采集到的视频图像,并且尽快实时刷新,此窗口有标题栏用于显示状态。同时,一定条件下,需要在视频上弹出一个对话框但不能影响不被对话框遮挡的区域的视频刷新。方法如下:
建立一个Window和Dialog,Window作为主UI,并建立定时器。
定时器实时获取AllocatedRegion后,将摄像头的数据直接刷新到FrameBuffer上。
当Dialog没有显示时,视频的刷新区域是除Window外的所有屏幕区域。
当Dialog显示时,视频的刷新区域还要减去Dialog的显示区域。
- QT之QDirectPainter使用
- QT之sqllite使用
- Qt之UDP使用
- QT之QFileSystemWatcher使用
- Qt之QSS使用
- Qt之MVC使用
- Qt之使用qmake
- Qt之QSS使用
- Qt使用教程之添加Qt版本
- QT之标准对话框使用
- Qt之简单使用Json
- Qt之QTableWidget详细使用
- Qt之QTableView的使用
- QT之QSetting的使用
- qt之菜单的使用
- qt之工具栏的使用
- Qt之QButtonGroup简单使用
- Qt之stylesheet使用介绍
- kafka 学习
- 两个超大数相乘 和两个超大数相加
- Echart配置对象异步初始化问题
- Kyle 的 iOS 面试题
- 织梦的if(!defined('DEDEINC')) exit("Request Error!");解析
- QT之QDirectPainter使用
- TCP的交互数据流与成块数据流
- oracle级联操作
- ListView.setOnItemClickListener无效问题的解决
- JAVA学习笔记(二) - 运算符
- 关于iOS和OS X废弃的API你需要知道的一切
- WPF-MVVM模式学习笔记5——NotificationObject学习
- 延时执行
- POJ 1584 A Round Peg in a Ground Hole(点到直线距离,圆与多边形相交,多边形是否为凸)