diff --git a/calendar-client/src/customWidget/cdateedit.cpp b/calendar-client/src/customWidget/cdateedit.cpp index eda93a27..0975a06c 100644 --- a/calendar-client/src/customWidget/cdateedit.cpp +++ b/calendar-client/src/customWidget/cdateedit.cpp @@ -115,7 +115,7 @@ void CDateEdit::slotRefreshLineEditTextFormat(const QString &text) { QFont font = lineEdit()->font(); QFontMetrics fm(font); - int textWidth = fm.width(text); + int textWidth = fm.horizontalAdvance(text); int maxWidth = lineEdit()->width() - 25; //文本能正常显示的最大宽度 if (textWidth > maxWidth) { setToolTip(text); @@ -224,7 +224,7 @@ bool CDateEdit::showGongli() { QString str = m_strCurrrentDate; QFontMetrics fontMetrice(lineEdit()->font()); - if (fontMetrice.width(str) > lineEdit()->width() - 20) { + if (fontMetrice.horizontalAdvance(str) > lineEdit()->width() - 20) { return false; } return true; diff --git a/calendar-client/src/customWidget/colorWidget/colorpickerWidget.cpp b/calendar-client/src/customWidget/colorWidget/colorpickerWidget.cpp index d8cd4bd3..fbb80757 100644 --- a/calendar-client/src/customWidget/colorWidget/colorpickerWidget.cpp +++ b/calendar-client/src/customWidget/colorWidget/colorpickerWidget.cpp @@ -117,7 +117,7 @@ void CColorPickerWidget::setLabelText() { } QString str = m_strColorLabel; QFontMetrics fontMetrice(m_wordLabel->font()); - if(fontMetrice.width(str) > (m_wordLabel->width()+4)) { + if(fontMetrice.horizontalAdvance(str) > (m_wordLabel->width()+4)) { str = fontMetrice.elidedText(str,Qt::ElideRight,m_wordLabel->width()); } m_wordLabel->setText(str); diff --git a/calendar-client/src/customWidget/ctitlewidget.cpp b/calendar-client/src/customWidget/ctitlewidget.cpp index 6ce2b624..c9b0d3a5 100644 --- a/calendar-client/src/customWidget/ctitlewidget.cpp +++ b/calendar-client/src/customWidget/ctitlewidget.cpp @@ -240,7 +240,7 @@ void CTitleWidget::resizeEvent(QResizeEvent *event) } QString str = m_strPlaceHolder; QFontMetrics fontMetrice(m_searchEdit->font()); - if (fontMetrice.width(str) > (m_searchEdit->width() - 30) && m_clickShowLeft == false && !m_buttonBox->isHidden()) { + if (fontMetrice.horizontalAdvance(str) > (m_searchEdit->width() - 30) && m_clickShowLeft == false && !m_buttonBox->isHidden()) { str = fontMetrice.elidedText(str, Qt::ElideRight, m_searchEdit->width() - 30); m_searchEdit->setPlaceHolder(str); m_searchEdit->setPlaceholderText(str); @@ -263,7 +263,7 @@ void CTitleWidget::updateSearchEditPlaceHolder() { QString str = m_strPlaceHolder; QFontMetrics fontMetrice(m_searchEdit->font()); - if (fontMetrice.width(str) > (m_searchEdit->width() - 30)) { + if (fontMetrice.horizontalAdvance(str) > (m_searchEdit->width() - 30)) { str = fontMetrice.elidedText(str, Qt::ElideRight, m_searchEdit->width() - 30); m_searchEdit->setPlaceHolder(str); m_searchEdit->setPlaceholderText(str); diff --git a/calendar-client/src/customWidget/customframe.cpp b/calendar-client/src/customWidget/customframe.cpp index 310835c8..0d139214 100644 --- a/calendar-client/src/customWidget/customframe.cpp +++ b/calendar-client/src/customWidget/customframe.cpp @@ -51,7 +51,7 @@ void CustomFrame::setTextStr(const QString &strc) if (!m_fixsizeflag) { QFontMetrics fm(m_font); - int w = fm.width(m_text); + int w = fm.horizontalAdvance(m_text); setMinimumWidth(w); } update(); @@ -69,7 +69,7 @@ void CustomFrame::setTextFont(const QFont &font) if (!m_fixsizeflag) { QFontMetrics fm(m_font); - int w = fm.width(m_text); + int w = fm.horizontalAdvance(m_text); setMinimumWidth(w); } } diff --git a/calendar-client/src/customWidget/jobtypelistview.cpp b/calendar-client/src/customWidget/jobtypelistview.cpp index 72f7b15b..d5b28d5b 100644 --- a/calendar-client/src/customWidget/jobtypelistview.cpp +++ b/calendar-client/src/customWidget/jobtypelistview.cpp @@ -454,7 +454,7 @@ void JobTypeListViewStyle::paint(QPainter *painter, const QStyleOptionViewItem & // 获取当前字体的信息 QFontMetrics fontMetrics(opt.font); // 当前文字长度是否大于显示框长度 - if (fontMetrics.width(displayName) > (opt.rect.width() - 90)) { + if (fontMetrics.horizontalAdvance(displayName) > (opt.rect.width() - 90)) { displayName = fontMetrics.elidedText(displayName, Qt::ElideRight, opt.rect.width() - 90); // 截取字符串长度用...代替 } if (view && view->m_iIndexCurrentHover == index.row()) { diff --git a/calendar-client/src/customWidget/scheduleRemindWidget.cpp b/calendar-client/src/customWidget/scheduleRemindWidget.cpp index 0293be07..a931f0da 100644 --- a/calendar-client/src/customWidget/scheduleRemindWidget.cpp +++ b/calendar-client/src/customWidget/scheduleRemindWidget.cpp @@ -118,7 +118,7 @@ void CenterWidget::UpdateTextList() { testList.clear(); QFontMetrics metrics(textfont); - textwidth = metrics.width(m_ScheduleInfo->summary()); + textwidth = metrics.horizontalAdvance(m_ScheduleInfo->summary()); textheight = metrics.height(); const int h_count = qCeil(textwidth / textRectWidth); QString text; @@ -131,7 +131,7 @@ void CenterWidget::UpdateTextList() for (int i = 0; i < m_ScheduleInfo->summary().count(); ++i) { text += m_ScheduleInfo->summary().at(i); - if (metrics.width(text) > textRectWidth) { + if (metrics.horizontalAdvance(text) > textRectWidth) { text.remove(text.count() - 1, 1); testList.append(text); text = ""; @@ -172,7 +172,7 @@ void CenterWidget::paintEvent(QPaintEvent *e) QFontMetrics metrics(timeFont); if (m_ScheduleInfo->allDay()) timestr = tr("All Day"); - int timewidth = metrics.width(timestr); + int timewidth = metrics.horizontalAdvance(timestr); int timeheight = metrics.height(); painter.drawText(QRect(x + 13, 7, timewidth, timeheight), Qt::AlignLeft | Qt::AlignTop, timestr); diff --git a/calendar-client/src/customWidget/timeedit.cpp b/calendar-client/src/customWidget/timeedit.cpp index 6a3885b3..d4c1bed6 100644 --- a/calendar-client/src/customWidget/timeedit.cpp +++ b/calendar-client/src/customWidget/timeedit.cpp @@ -196,7 +196,7 @@ void CTimeEdit::showPopup() int maxLen = 0; QFontMetrics fontMet(view()->font()); for (int i = 0 ; i < count() ; ++i) { - int &&itemWidth = fontMet.width(this->itemText(i)); + int &&itemWidth = fontMet.horizontalAdvance(this->itemText(i)); maxLen = qMax(maxLen, itemWidth); } maxLen += 45; //选项前√占用的大小 diff --git a/calendar-client/src/dialog/myscheduleview.cpp b/calendar-client/src/dialog/myscheduleview.cpp index 26a3f5e3..1a7d2a37 100644 --- a/calendar-client/src/dialog/myscheduleview.cpp +++ b/calendar-client/src/dialog/myscheduleview.cpp @@ -64,7 +64,7 @@ void CMyScheduleView::slotAutoFeed(const QFont &font) labelF.setWeight(QFont::Medium); labelF = DFontSizeManager::instance()->get(DFontSizeManager::T6, labelF); QFontMetrics fm(labelF); - int titlewidth = fm.width(strText); + int titlewidth = fm.horizontalAdvance(strText); QStringList strList; QString str; int h = fm.height(); @@ -77,7 +77,7 @@ void CMyScheduleView::slotAutoFeed(const QFont &font) for (int i = 0; i < strText.count(); i++) { str += strText.at(i); - if (fm.width(str) > 330) { + if (fm.horizontalAdvance(str) > 330) { str.remove(str.count() - 1, 1); strList.append(str); resultStr += str + "\n"; @@ -108,7 +108,7 @@ void CMyScheduleView::slotAutoFeed(const QFont &font) if (index != -1) { timeName[index - 1] = ' '; QFontMetrics fm(m_timeLabel->font()); - int textWidth = fm.width(m_timeLabel->text()); + int textWidth = fm.horizontalAdvance(m_timeLabel->text()); if (textWidth > m_timeLabel->width()) { timeName[index - 1] = '\n'; m_timeLabelH = 58; diff --git a/calendar-client/src/dialog/schedulectrldlg.cpp b/calendar-client/src/dialog/schedulectrldlg.cpp index 0e06fef2..7c98c658 100644 --- a/calendar-client/src/dialog/schedulectrldlg.cpp +++ b/calendar-client/src/dialog/schedulectrldlg.cpp @@ -122,8 +122,8 @@ void CScheduleCtrlDlg::changeEvent(QEvent *event) QFontMetrics font_button(font); QFontMetrics font_firstLabel(font); QFontMetrics font_seconLabel(font); - int height_firstLabel = (font_firstLabel.width(m_firstLabel->text()) / 300 + 1) * font_firstLabel.height(); - int height_seconLabel = (font_seconLabel.width(m_seconLabel->text()) / 300 + 1) * font_seconLabel.height(); + int height_firstLabel = (font_firstLabel.horizontalAdvance(m_firstLabel->text()) / 300 + 1) * font_firstLabel.height(); + int height_seconLabel = (font_seconLabel.horizontalAdvance(m_seconLabel->text()) / 300 + 1) * font_seconLabel.height(); for (int i = 0; i < buttonCount(); i++) { QAbstractButton *button = getButton(i); diff --git a/calendar-client/src/view/graphicsItem/calldayscheduleitem.cpp b/calendar-client/src/view/graphicsItem/calldayscheduleitem.cpp index 34028a12..a4ca3fe3 100644 --- a/calendar-client/src/view/graphicsItem/calldayscheduleitem.cpp +++ b/calendar-client/src/view/graphicsItem/calldayscheduleitem.cpp @@ -71,15 +71,15 @@ void CAllDayScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, tSTitleName.replace("\n", ""); QString str = tSTitleName; QString tStr; - int _rightOffset = fm.width("..."); + int _rightOffset = fm.horizontalAdvance("..."); //显示宽度 左侧偏移13右侧偏移8 qreal _showWidth = fillRect.width() - 13 - 8 - m_offset * 2; //如果标题总长度大于显示长度则显示长度须减去"..."的长度 - if (fm.width(str) > _showWidth) { + if (fm.horizontalAdvance(str) > _showWidth) { _showWidth -= _rightOffset; for (int i = 0; i < str.count(); i++) { tStr.append(str.at(i)); - int widthT = fm.width(tStr); + int widthT = fm.horizontalAdvance(tStr); //如果宽度大于显示长度则去除最后添加的字符 if (widthT > _showWidth) { tStr.chop(1); diff --git a/calendar-client/src/view/graphicsItem/cmonthdayitem.cpp b/calendar-client/src/view/graphicsItem/cmonthdayitem.cpp index 98b321a2..88c2bb08 100644 --- a/calendar-client/src/view/graphicsItem/cmonthdayitem.cpp +++ b/calendar-client/src/view/graphicsItem/cmonthdayitem.cpp @@ -160,7 +160,7 @@ void CMonthDayItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt //绘制农历 if (m_LunarVisible) { QFontMetrics metrics(m_LunerFont); - int Lunarwidth = metrics.width(m_DayLunar); + int Lunarwidth = metrics.horizontalAdvance(m_DayLunar); qreal filleRectX = this->rect().width() - 12 - 3 - (58 + Lunarwidth) / 2; QRectF fillRectT(this->rect().x() + filleRectX, this->rect().y() + 9, diff --git a/calendar-client/src/view/graphicsItem/cmonthscheduleitem.cpp b/calendar-client/src/view/graphicsItem/cmonthscheduleitem.cpp index ec76cb9d..a26160ab 100644 --- a/calendar-client/src/view/graphicsItem/cmonthscheduleitem.cpp +++ b/calendar-client/src/view/graphicsItem/cmonthscheduleitem.cpp @@ -92,15 +92,15 @@ void CMonthScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, //右侧偏移8 qreal textWidth = labelwidth - m_pos.x() - m_offset * 2 - 8; QString tStr; - int _rightOffset = fm.width("..."); + int _rightOffset = fm.horizontalAdvance("..."); //显示宽度 左侧偏移13右侧偏移8 qreal _showWidth = textWidth; //如果标题总长度大于显示长度则显示长度须减去"..."的长度 - if (fm.width(str) > _showWidth) { + if (fm.horizontalAdvance(str) > _showWidth) { _showWidth -= _rightOffset; for (int i = 0; i < str.count(); i++) { tStr.append(str.at(i)); - int widthT = fm.width(tStr); + int widthT = fm.horizontalAdvance(tStr); //如果宽度大于显示长度则去除最后添加的字符 if (widthT > _showWidth) { tStr.chop(1); diff --git a/calendar-client/src/view/graphicsItem/cmonthschedulenumitem.cpp b/calendar-client/src/view/graphicsItem/cmonthschedulenumitem.cpp index ce405571..a3d81e87 100644 --- a/calendar-client/src/view/graphicsItem/cmonthschedulenumitem.cpp +++ b/calendar-client/src/view/graphicsItem/cmonthschedulenumitem.cpp @@ -82,7 +82,7 @@ void CMonthScheduleNumItem::paint(QPainter *painter, const QStyleOptionGraphicsI QString tStr; for (int i = 0; i < str.count(); i++) { tStr.append(str.at(i)); - int widthT = fm.width(tStr) + 5; + int widthT = fm.horizontalAdvance(tStr) + 5; if (widthT >= labelwidth) { tStr.chop(2); break; diff --git a/calendar-client/src/view/graphicsItem/scheduleitem.cpp b/calendar-client/src/view/graphicsItem/scheduleitem.cpp index 6995aab9..a36a51de 100644 --- a/calendar-client/src/view/graphicsItem/scheduleitem.cpp +++ b/calendar-client/src/view/graphicsItem/scheduleitem.cpp @@ -80,7 +80,7 @@ void CScheduleItem::splitText(QFont font, int w, int h, QString str, QStringList for (int i = 0; i < str.count(); i++) { tStr.append(str.at(i)); - int widthT = fontMetrics.width(tStr) + 5; + int widthT = fontMetrics.horizontalAdvance(tStr) + 5; if (widthT >= w) { tStr.chop(1); @@ -107,7 +107,7 @@ void CScheduleItem::splitText(QFont font, int w, int h, QString str, QStringList QString c = str.at(0); QString str = c + "..."; QFontMetrics fm(font); - while (f_st.width(str) > w && f_st.width(str) > 24) { + while (f_st.horizontalAdvance(str) > w && f_st.horizontalAdvance(str) > 24) { str.chop(1); } listStr.append(str); @@ -255,11 +255,11 @@ void CScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, const QFontMetrics fontMetrics(font); qreal drawTextWidth = rect.width() - m_offset * 2; - if (fm.width(str) > drawTextWidth - 5) { + if (fm.horizontalAdvance(str) > drawTextWidth - 5) { QString tStr; for (int i = 0; i < str.count(); i++) { tStr.append(str.at(i)); - int widthT = fm.width(tStr) - 5; + int widthT = fm.horizontalAdvance(tStr) - 5; if (widthT >= drawTextWidth) { if (i < 1) { diff --git a/calendar-client/src/widget/schedulesearchview.cpp b/calendar-client/src/widget/schedulesearchview.cpp index f15c4fb4..2d826308 100644 --- a/calendar-client/src/widget/schedulesearchview.cpp +++ b/calendar-client/src/widget/schedulesearchview.cpp @@ -294,7 +294,7 @@ void CScheduleSearchItem::paintEvent(QPaintEvent *e) for (int i = 0; i < str.count(); i++) { tStr.append(str.at(i)); tStr.append(ellipsis); - int widthT = fm.width(tStr); + int widthT = fm.horizontalAdvance(tStr); tStr.remove(ellipsis); if (widthT >= tilenameW) { tStr.chop(1); diff --git a/calendar-client/src/widget/weekWidget/weekheadview.cpp b/calendar-client/src/widget/weekWidget/weekheadview.cpp index 8bf2982e..5424832f 100644 --- a/calendar-client/src/widget/weekWidget/weekheadview.cpp +++ b/calendar-client/src/widget/weekWidget/weekheadview.cpp @@ -327,7 +327,7 @@ void CWeekHeadView::paintCell(QWidget *cell) QFontMetrics fm = painter.fontMetrics(); - while (fm.width(dayWeek) > cell->width() / 2) + while (fm.horizontalAdvance(dayWeek) > cell->width() / 2) dayWeek.chop(1); //水平右对齐,上下居中 painter.drawText(QRect(0, bh, (cell->width() / 2), 26), Qt::AlignRight | Qt::AlignVCenter, dayWeek); diff --git a/calendar-client/src/widget/yearWidget/yearscheduleview.cpp b/calendar-client/src/widget/yearWidget/yearscheduleview.cpp index 6510e6d2..d798316a 100644 --- a/calendar-client/src/widget/yearWidget/yearscheduleview.cpp +++ b/calendar-client/src/widget/yearWidget/yearscheduleview.cpp @@ -246,7 +246,7 @@ void CYearScheduleView::paintItem(QPainter &painter, DSchedule::Ptr info, int in for (int i = 0; i < str.count(); i++) { tStr.append(str.at(i)); - int widthT = fm.width(tStr) + 5; + int widthT = fm.horizontalAdvance(tStr) + 5; if (widthT >= tilenameW) { tStr.chop(1); break;