painter.setPen(m_myPenColor);//(QPen(m_myPenColor, myPenWidth,
painter.
setBrush(QBrush(m_myPenColor
));
painter.setFont(m_myFont );
qreal pixelsHigh = fm.height();
qreal pixelwidthMil = fm.width("First Text");
qreal pixelwidthMm = fm.width("Second Text");
qreal pixelWidthMax= (pixelwidthMil>=pixelwidthMm)?pixelwidthMil:pixelwidthMm;
int iX=0,iY=0;
iX = endPoint.x();
iY = endPoint.y()+(int)pixelsHigh;
painter.drawText(iX+2, iY, "First Text");
iY = iY + (int)pixelsHigh+1;
painter.drawText(iX+2, iY, "Second Text");
pixelsHigh = (pixelsHigh*2)+6;
pixelWidthMax = pixelWidthMax+6;
update(endPoint.x()-2, endPoint.y()-2, (int)pixelWidthMax,(int)pixelsHigh);
QPainter painter(&image);
painter.setPen(m_myPenColor);//(QPen(m_myPenColor, myPenWidth,
painter.setBrush(QBrush(m_myPenColor));
painter.setFont(m_myFont );
QFontMetricsF fm(m_myFont);
qreal pixelsHigh = fm.height();
qreal pixelwidthMil = fm.width("First Text");
qreal pixelwidthMm = fm.width("Second Text");
qreal pixelWidthMax= (pixelwidthMil>=pixelwidthMm)?pixelwidthMil:pixelwidthMm;
int iX=0,iY=0;
iX = endPoint.x();
iY = endPoint.y()+(int)pixelsHigh;
painter.drawText(iX+2, iY, "First Text");
iY = iY + (int)pixelsHigh+1;
painter.drawText(iX+2, iY, "Second Text");
pixelsHigh = (pixelsHigh*2)+6;
pixelWidthMax = pixelWidthMax+6;
update(endPoint.x()-2, endPoint.y()-2, (int)pixelWidthMax,(int)pixelsHigh);
To copy to clipboard, switch view to plain text mode
Bookmarks