Ejemplo n.º 1
0
void FancyLabel::paintEvent(QPaintEvent *) {

    QPainter painter(this);
    if(!m_generated){
        painter.save();
        if(m_opacity !=1)
            { painter.setOpacity(m_opacity);}
        int newSectionHeight = m_sectionHeight +
                               (m_currentHeight - m_originalImage.height());
        QSize stretchSize(m_middle.width(),newSectionHeight);

        QImage scaledMiddle = m_middle.scaled(stretchSize, Qt::IgnoreAspectRatio);

        painter.drawImage(QPoint(0,0), m_top);
        int midTop = m_top.height();
        painter.drawImage(QPoint(0,midTop), scaledMiddle);
        int midBottom = midTop +scaledMiddle.height();
        painter.drawImage(QPoint(0,midBottom), m_bottom);
        painter.restore();
    } else {
        painter.save();
        for(int i=m_pPaths.count()-1; i>=0;i--){
            painter.fillPath(m_pPaths[i].first, m_pPaths[i].second );
            //painter.drawPixmap(m_marginRect,m_backgroundImage);
        }
        painter.restore();


    }


}
Ejemplo n.º 2
0
void FancyLabel::paintEvent(QPaintEvent *) {

    QPainter p(this);
    int newSectionHeight = m_sectionHeight +
                           (m_currentHeight - m_originalImage.height());
    QSize stretchSize(m_middle.width(),newSectionHeight);

    QImage scaledMiddle = m_middle.scaled(stretchSize, Qt::IgnoreAspectRatio);

    p.drawImage(QPoint(0,0), m_top);
    int midTop = m_top.height();
    p.drawImage(QPoint(0,midTop), scaledMiddle);
    int midBottom = midTop +scaledMiddle.height();
    p.drawImage(QPoint(0,midBottom), m_bottom);

}