我无法使用QPainter drawText()方法绘制路径
QString Path = "/home/User"
QPainter *painter
QRectF centerRect = QRectF (textX,centerY + m_bounds.height()*0.15, fm.width(Path),fm.height());
painter->drawText(centerRect,Path,QTextOption(Qt::AlignCenter | Qt::AlignHCenter ));
在Windows中它绘制文本但在ubunthu Linux上只显示/ home
答案 0 :(得分:0)
QFontMetrics fm = painter->fontMetrics();
qreal centerY = ( m_bounds.height() - fm.height() -10 )/2;
qreal textX = 8;
QRectF centerRect = QRectF (textX,centerY + m_bounds.height()*0.15, fm.width(m_folderPath),fm.height());
painter->drawText(centerRect,m_folderPath,QTextOption(Qt::AlignCenter | Qt::AlignHCenter ));
fm.width(m_folderPath)
显示/ home / user和/ homeuser4
的不同值