Red de conocimiento informático - Problemas con los teléfonos móviles - Programación de QT para leer letras

Programación de QT para leer letras

Primero una foto.

fillRect(QRect(0,?0,?paintw,?rtText.height()),?QBrush(Qt::white));

pTmp.fillRect(QRect(0,?0,?mPrecent ,?rtText.height()),?QBrush(Qt::blue));

pTmp.setCompositionMode(QPainter::CompositionMode_DestinationIn);

pTmp.drawImage(0,? 0,?pmMask);

pTmp.setCompositionMode(QPainter::CompositionMode_DestinationOver);

Funciones principales:

void?testLyrics::DrawLyric(QPainter?& . p,?const?QRect&?rt)

{

p.setBrush(Qt::darkGray);

p.drawRect(rect()) ?

const?QString?strLyric?=?mCurLyrics.lyric;

QFont?m_ftLyric(QString::fromLocal8Bit("Microsoft Yahei"),?24,?QFont:: Negrita);

QPainter?pTmp;

QFontMetrics?fm(m_ftLyric);

QSize?textSize?=?fm.size(Qt::TextSingleLine, ?strLyric);

QRect?textRect(QPoint(0,0),textSize);

int?paintw?=?textSize.width();

int?playedW?=?textSize.width()*0.5;

QRect?rtText?=?rect();

//?pTmp.setRenderHints(QPainter::TextAntialiasing ,?true);

QImage?p>pTmp.setPen(Qt::black);

pTmp.drawText(pmMask.rect(),?strLyric);

}

pTmp.end();

QImage?pmFG(paintw,?rtText .height(),QImage::Format_ARGB32);

if?(pTmp.begin(&pmFG))

{

pTmp.setCompositionMode(QPainter::CompositionMode _Source);

pTmp.fillRect(QRect( 0,?0,?paintw,?rtText.height()),?QBrush(Qt::white));

pTmp.fillRect(QRect(0,?0,?paintw,?rtText. height()),?fillRect(QRect(0,?0,?mPrecent,?rtText.height()),?QBrush(Qt::blue));

pTmp.setCompositionMode(QPainter:: ComposiciónMod

e_DestinationIn);

pTmp.drawImage(0,?0,?pmMask);

pTmp.setCompositionMode(QPainter::CompositionMode_DestinationOver);

/?Shadow

pTmp.setFont(m_ftLyric);

pTmp.setPen(QColor(0,0,0,0x80));

pTmp.drawText(pmMask. rect(),?strLyric);

}

pTmp.end();

p.drawImage(rtText.left(),?rtText.top (),?pmFG);

}