• Qt PNG 背景透明


    本文主要是解决Qt中QGraphicsAbstractShapeItem,QPixmap,QPainter等组件的透明化显示问题。

    在Qt中定义了一个常量,用于设置透明的颜色,即Qt::transparent,表示RGBA值为(0,0,0,0)的透明色。

    在QGraphicsAbstractShapeItem的集成类中,可以把某些部分画成Qt::transparent来设置透明。

    在QPainter中,可以通过setBackgroundMode()选择两种不同的背景模式,一种是Qt::TransparentMode,另外一种是Qt::OpaqueMode。在Qt::TransparentMode模式下,背景本身就是透明的,此时QPainter的setBackground()函数不起作用;在Qt::OpaqueMode模式下,通过QPainter的setBackground()函数来设置QPainter类对象的背景色,在此模式下,也可以设置背景色为Qt::transparent。

    有时,我们要把QPainter画到QPixmap中以防止闪烁。如果需要设置QPixmap的透明,可以先用QPixmap的fill()函数先把场景设置成透明的(fill(Qt::transparent) )。

    QImage::fill ( uint pixelValue)
    试试用这个填充透明色。

    theImage.fill(qRgba(255,255,255,0));

    http://www.cnblogs.com/cainiaoaixuexi/p/3238092.html

    http://blog.csdn.net/u012234115/article/details/43778855

    http://blog.csdn.net/yiyaaixuexi/article/details/6362865

    http://www.qtcn.org/bbs/simple/?t54707.html

  • 相关阅读:
    关于Java中System.currentTimeMillis和System.nanoTime的错误认识
    多线程以外
    vim 小技巧
    Virtual Box HostOnly网络模式配置
    How 30 Minutes a Day Can Increase Your Intelligence
    YUM命令使用
    Hash算法及其应用
    jetty + apache httpd 反向代理配置
    使用SCTP优化网络
    .NET书籍推荐
  • 原文地址:https://www.cnblogs.com/findumars/p/6895608.html
Copyright © 2020-2023  润新知