Необходимо расчитать высоту ячейки по имеющемся в неё тексту.
Использую такой очевидный код:
qreal uoReportDoc::doFormatCellText(uoCell* cell, QFont* font, QFontMetricsF& fm, const qreal& collWidth)
{
qreal cellHeight = 0.0;
QString cellStr = cell->getText();
if (cellStr.isEmpty())
return cellHeight;
int lenAll = cellStr.length();
QChar chrLS = '\n';
int pos = cellStr.indexOf(chrLS, 0);
if (pos != -1){
QStringList strList = cellStr.split(chrLS);
cellHeight = fm.height()*strList.size();
}
return cellHeight;
}
Выкручиваюсь собственно вот так:
qreal uoReportDoc::doFormatCellText(uoCell* cell, QFont* font, QFontMetricsF& fm, const qreal& collWidth)
{
qreal cellHeight = 0.0;
QString cellStr = cell->getText();
if (cellStr.isEmpty())
return cellHeight;
int lenAll = cellStr.length();
QChar chrLS = '\n';
int pos = cellStr.indexOf(chrLS, 0);
if (pos != -1){
QStringList strList = cellStr.split(chrLS);
cellHeight = (fm.lineSpacing()-fm.descent()) *strList.size() + fm.descent(); <<<<<<<<<<<<<<<<<<<<<<<<<<<
}
return cellHeight;
}
Но всеравно чувствую, что это выход через задницу и он даст где-то сбой.
Сообщение отредактировал trdm - 30.9.2008, 11:37
Эскизы прикрепленных изображений
 РЈРСВВеньшено Р В Р’В Р СћРІР‚ВР С• 46%
484 x 535 (45.38 килобайт)
|
 РЈРСВВеньшено Р В Р’В Р СћРІР‚ВР С• 50%
526 x 463 (45.48 килобайт)
|