当前位置:网站首页>QT elidedtext only works for Chinese conformity, but not for English

QT elidedtext only works for Chinese conformity, but not for English

2022-06-23 05:04:00 Brother Dashi

QString strNodeName = “ Only for Chinese to meet your role ”; 
//QString strNodeName = “only yuo only yuo only yuoonly yuo only yuo only yuo ”; 
const QString elidedIdNew = fm.elidedText(strNodeName,
                                                   Qt::ElideMiddle,
                                                  100);

I find it doesn't work for English at all , At first I thought there was a problem with the width , After printing out the width, it is found that it is also normal , I finally found out that , Imaged

pixelSize() by 0
 qreal nPix = painter->font().pixelSize();

        qDebug("nPix %d",  nPix);

Set the font size you want before calling the solution :

 QFont font = painter->font();
        //TODO: change font size
        font.setPixelSize(9);
        painter->setFont(font);

Problem solving

原网站

版权声明
本文为[Brother Dashi]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206222341373091.html