Added Qt dependent macro for QFontMetrics::horizontalAdvance/width

This commit is contained in:
thunder2 2025-07-21 15:04:57 +02:00
parent fad7774767
commit fce618f2aa
17 changed files with 66 additions and 48 deletions

View file

@ -33,6 +33,7 @@
#include <retroshare/rsdisc.h>
#include <retroshare/rspeers.h>
#include "settings/rsharesettings.h"
#include "util/RsQtVersion.h"
#include <QClipboard>
#include <QSysInfo>
@ -306,7 +307,7 @@ void AWidget::drawBitField()
AWidget::AWidget()
: page(0), density(5)
, mImagesReady(false), mState(0), mTimerId(0)
, mStep(1.0f), mMaxStep(QFontMetricsF(font()).width(' '))
, mStep(1.0f), mMaxStep(QFontMetrics_horizontalAdvance(QFontMetricsF(font()), ' '))
{
setMouseTracking(true);
//startTimer(15);

View file

@ -38,6 +38,7 @@
#include "gui/gxs/GxsIdDetails.h"
#include "gui/Identity/IdDialog.h"
#include "gui/Identity/IdEditDialog.h"
#include "util/RsQtVersion.h"
//#define DEBUG_CREATE_CIRCLE_DIALOG 1
@ -74,7 +75,7 @@ CreateCircleDialog::CreateCircleDialog()
ui.IdFilter->addFilter(QIcon(), headerText, RSCIRCLEID_COL_KEYID, QString("%1 %2").arg(tr("Search"), headerText));
/* Set initial column width */
int fontWidth = QFontMetricsF(ui.treeWidget_IdList->font()).width("W");
int fontWidth = QFontMetrics_horizontalAdvance(QFontMetricsF(ui.treeWidget_IdList->font()), "W");
ui.treeWidget_IdList->setColumnWidth(RSCIRCLEID_COL_NICKNAME, 17 * fontWidth);
ui.treeWidget_membership->setColumnWidth(RSCIRCLEID_COL_NICKNAME, 17 * fontWidth);

View file

@ -30,6 +30,7 @@
#include "DLListDelegate.h"
#include "util/DateTime.h"
#include "util/RsQtVersion.h"
Q_DECLARE_METATYPE(FileProgressInfo)
@ -278,7 +279,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
QSize DLListDelegate::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const
{
float w = QFontMetricsF(option.font).width(index.data(Qt::DisplayRole).toString());
float w = QFontMetrics_horizontalAdvance(QFontMetricsF(option.font), index.data(Qt::DisplayRole).toString());
int S = QFontMetricsF(option.font).height()*1.5 ;
return QSize(w,S);

View file

@ -22,6 +22,7 @@
#include "ULListDelegate.h"
#include "xprogressbar.h"
#include "util/RsQtVersion.h"
Q_DECLARE_METATYPE(FileProgressInfo)
@ -179,7 +180,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
QSize ULListDelegate::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const
{
float w = QFontMetricsF(option.font).width(index.data(Qt::DisplayRole).toString());
float w = QFontMetrics_horizontalAdvance(QFontMetricsF(option.font), index.data(Qt::DisplayRole).toString());
int S = QFontMetricsF(option.font).height()*1.5 ;
return QSize(w,S);

View file

@ -394,7 +394,7 @@ IdDialog::IdDialog(QWidget *parent)
/* Set initial section sizes */
QHeaderView * circlesheader = ui->treeWidget_membership->header () ;
circlesheader->resizeSection (CIRCLEGROUP_CIRCLE_COL_GROUPNAME, fm.width("Circle name")*1.5) ;
circlesheader->resizeSection (CIRCLEGROUP_CIRCLE_COL_GROUPNAME, QFontMetrics_horizontalAdvance(fm, "Circle name")*1.5) ;
ui->treeWidget_membership->setColumnWidth(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, 270);
/* Setup tree */

View file

@ -20,6 +20,7 @@
#include "gui/common/FilesDefs.h"
#include "LineEditClear.h"
#include "util/RsQtVersion.h"
#include <QToolButton>
#include <QStyle>
@ -237,7 +238,7 @@ void LineEditClear::setFilterButtonIcon(const QIcon &icon)
ensurePolished();
#if !defined(Q_OS_DARWIN)
QFontMetrics fm(this->font());
QSize size(fm.width("___"), fm.height());
QSize size(QFontMetrics_horizontalAdvance(fm, "___"), fm.height());
mFilterButton->setFixedSize(size);
mFilterButton->setIconSize(size);
#endif

View file

@ -35,6 +35,7 @@
#include <retroshare-gui/RsAutoUpdatePage.h>
#include "rshare.h"
#include "RSGraphWidget.h"
#include "util/RsQtVersion.h"
#if QT_VERSION < 0x040700
#include <sys/time.h>
@ -655,12 +656,12 @@ void RSGraphWidget::paintScale1()
if (_flags & RSGRAPH_FLAGS_DARK_STYLE){
_painter->setPen(SCALE_COLOR_DARK);
_painter->drawText(QPointF(SCALE_WIDTH*fact - QFontMetricsF(font()).width(text) - 4*fact, pos+0.4*FS), text);
_painter->drawText(QPointF(SCALE_WIDTH*fact - QFontMetrics_horizontalAdvance(QFontMetricsF(font()), text) - 4*fact, pos+0.4*FS), text);
_painter->setPen(GRID_COLOR_DARK);
_painter->drawLine(QPointF(SCALE_WIDTH*fact, pos), QPointF(_rec.width(), pos));
}else{
_painter->setPen(SCALE_COLOR);
_painter->drawText(QPointF(SCALE_WIDTH*fact - QFontMetricsF(font()).width(text) - 4*fact, pos+0.4*FS), text);
_painter->drawText(QPointF(SCALE_WIDTH*fact - QFontMetrics_horizontalAdvance(QFontMetricsF(font()), text) - 4*fact, pos+0.4*FS), text);
_painter->setPen(GRID_COLOR);
_painter->drawLine(QPointF(SCALE_WIDTH*fact, pos), QPointF(_rec.width(), pos));
}

View file

@ -38,6 +38,7 @@
#include "edge.h"
#include "elnode.h"
#include "graphwidget.h"
#include "util/RsQtVersion.h"
#define IMAGE_AUTHED ":/images/accepted16.png"
#define IMAGE_DENIED ":/images/denied16.png"
@ -313,7 +314,7 @@ void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
if (!mDeterminedBB)
{
QRect textBox = painter->boundingRect(-10, 5*f, QFontMetricsF(graph->font()).width(txt), 1.5*m, Qt::AlignVCenter, QString::fromUtf8(_desc_string.c_str()));
QRect textBox = painter->boundingRect(-10, 5*f, QFontMetrics_horizontalAdvance(QFontMetricsF(graph->font()), txt), 1.5*m, Qt::AlignVCenter, QString::fromUtf8(_desc_string.c_str()));
mBBWidth = textBox.width()+40*f;
mDeterminedBB = true;
}

View file

@ -355,9 +355,9 @@ QSize ChannelPostFilesDelegate::sizeHint(const QStyleOptionViewItem& option, con
switch(index.column())
{
case RsGxsChannelPostFilesModel::COLUMN_FILES_NAME: return QSize(1.1*fm.width(QString::fromUtf8(file.mName.c_str())),fm.height());
case RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE: return QSize(1.1*fm.width(misc::friendlyUnit(qulonglong(file.mSize))),fm.height());
case RsGxsChannelPostFilesModel::COLUMN_FILES_DATE: return QSize(1.1*fm.width(QDateTime::fromMSecsSinceEpoch(file.mPublishTime*1000).toString("MM/dd/yyyy, hh:mm")),fm.height());
case RsGxsChannelPostFilesModel::COLUMN_FILES_NAME: return QSize(1.1*QFontMetrics_horizontalAdvance(fm, QString::fromUtf8(file.mName.c_str())),fm.height());
case RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE: return QSize(1.1*QFontMetrics_horizontalAdvance(fm, misc::friendlyUnit(qulonglong(file.mSize))),fm.height());
case RsGxsChannelPostFilesModel::COLUMN_FILES_DATE: return QSize(1.1*QFontMetrics_horizontalAdvance(fm, QDateTime::fromMSecsSinceEpoch(file.mPublishTime*1000).toString("MM/dd/yyyy, hh:mm")),fm.height());
default:
case RsGxsChannelPostFilesModel::COLUMN_FILES_FILE: return QSize(option.rect.width(),GxsChannelFilesStatusWidget(file).height());
}
@ -463,8 +463,8 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI
QHeaderView * channelpostfilesheader = ui->channelPostFiles_TV->header () ;
QHeaderView * channelfilesheader = ui->channelFiles_TV->header () ;
channelpostfilesheader->resizeSection (RsGxsChannelPostFilesModel::COLUMN_FILES_NAME, fm.width("RetroShare-v0.6.5-1487-g6714648e5-Windows-x64-portable-20200518-Qt-5.14.2.7z"));
channelfilesheader->resizeSection (RsGxsChannelPostFilesModel::COLUMN_FILES_NAME, fm.width("RetroShare-v0.6.5-1487-g6714648e5-Windows-x64-portable-20200518-Qt-5.14.2.7z"));
channelpostfilesheader->resizeSection (RsGxsChannelPostFilesModel::COLUMN_FILES_NAME, QFontMetrics_horizontalAdvance(fm, "RetroShare-v0.6.5-1487-g6714648e5-Windows-x64-portable-20200518-Qt-5.14.2.7z"));
channelfilesheader->resizeSection (RsGxsChannelPostFilesModel::COLUMN_FILES_NAME, QFontMetrics_horizontalAdvance(fm, "RetroShare-v0.6.5-1487-g6714648e5-Windows-x64-portable-20200518-Qt-5.14.2.7z"));
/* Initialize feed widget */
//ui->feedWidget->setSortRole(ROLE_PUBLISH, Qt::DescendingOrder);

View file

@ -209,15 +209,15 @@ MessagesDialog::MessagesDialog(QWidget *parent)
ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_CONTENT,true);
ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_MSGID,true);
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_STAR, fm.width('0')*1.5);
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_ATTACHMENT, fm.width('0')*1.5);
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_READ, fm.width('0')*1.5);
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_SPAM, fm.width('0')*1.5);
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_STAR, QFontMetrics_horizontalAdvance(fm, '0')*1.5);
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_ATTACHMENT, QFontMetrics_horizontalAdvance(fm, '0')*1.5);
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_READ, QFontMetrics_horizontalAdvance(fm, '0')*1.5);
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_SPAM, QFontMetrics_horizontalAdvance(fm, '0')*1.5);
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_SUBJECT, fm.width("You have a message")*3.0);
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_AUTHOR, fm.width("[Retroshare]")*1.1);
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_TO, fm.width("[Retroshare]")*1.1);
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_DATE, fm.width("01/01/1970")*1.1);
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_SUBJECT, QFontMetrics_horizontalAdvance(fm, "You have a message")*3.0);
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_AUTHOR, QFontMetrics_horizontalAdvance(fm, "[Retroshare]")*1.1);
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_TO, QFontMetrics_horizontalAdvance(fm, "[Retroshare]")*1.1);
msgwheader->resizeSection (RsMessageModel::COLUMN_THREAD_DATE, QFontMetrics_horizontalAdvance(fm, "01/01/1970")*1.1);
msgwheader->setSectionResizeMode(RsMessageModel::COLUMN_THREAD_SUBJECT, QHeaderView::Interactive);
msgwheader->setSectionResizeMode(RsMessageModel::COLUMN_THREAD_AUTHOR, QHeaderView::Interactive);

View file

@ -37,6 +37,7 @@
#include <retroshare/rsservicecontrol.h>
#include "rsitems/rsserviceids.h"
#include <QTextDocument>
#include "util/RsQtVersion.h"
#define NOT_IMPLEMENTED std::cerr << __PRETTY_FUNCTION__ << ": not yet implemented." << std::endl;
@ -300,7 +301,7 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *)
if(name.length() > 20 + 3)
name = name.left(20)+"..." ;
peer_name_size = std::max(peer_name_size, fm.width(name)) ;
peer_name_size = std::max(peer_name_size, QFontMetrics_horizontalAdvance(fm, name)) ;
names.push_back(name) ;
}
@ -315,13 +316,13 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *)
for(std::list<RsPeerId>::const_iterator it(ssllist.begin());it!=ssllist.end();++it,++i)
{
float X = S*fMATRIX_START_X + peer_name_size - fm.width(names[i]) ;
float X = S*fMATRIX_START_X + peer_name_size - QFontMetrics_horizontalAdvance(fm, names[i]) ;
float Y = S*fMATRIX_START_Y + (i+0.5)*S*fROW_SIZE + line_height/2.0f-2 ;
_painter->drawText(QPointF(X,Y),names[i]) ;
if(*it == _current_peer_id)
_painter->drawLine(QPointF(X,Y+3),QPointF(X+fm.width(names[i]),Y+3)) ;
_painter->drawLine(QPointF(X,Y+3),QPointF(X+QFontMetrics_horizontalAdvance(fm, names[i]),Y+3)) ;
y += line_height ;
}
@ -336,7 +337,7 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *)
for(std::map<uint32_t, RsServiceInfo>::const_iterator it(ownServices.mServiceList.begin());it!=ownServices.mServiceList.end();++it,++i)
{
QString name = QString::fromUtf8(it->second.mServiceName.c_str()) ;
int text_width = fm.width(name) ;
int text_width = QFontMetrics_horizontalAdvance(fm, name) ;
int X = matrix_start_x + S*fCOL_SIZE/2 - 2 + i*S*fCOL_SIZE - text_width/2;
@ -490,11 +491,11 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *)
QFontMetrics fm(font);
int text_size_x = 0 ;
text_size_x = std::max(text_size_x,fm.width(service_name));
text_size_x = std::max(text_size_x,fm.width(peer_name));
text_size_x = std::max(text_size_x,fm.width(peer_id));
text_size_x = std::max(text_size_x,fm.width(local_status));
text_size_x = std::max(text_size_x,fm.width(remote_status));
text_size_x = std::max(text_size_x,QFontMetrics_horizontalAdvance(fm, service_name));
text_size_x = std::max(text_size_x,QFontMetrics_horizontalAdvance(fm, peer_name));
text_size_x = std::max(text_size_x,QFontMetrics_horizontalAdvance(fm, peer_id));
text_size_x = std::max(text_size_x,QFontMetrics_horizontalAdvance(fm, local_status));
text_size_x = std::max(text_size_x,QFontMetrics_horizontalAdvance(fm, remote_status));
// draw a half-transparent rectangle
@ -558,7 +559,7 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *)
QRect position = computeNodePosition(0,i,false) ;
int popup_x = position.x() + (50 * S / 14.0);
int popup_y = position.y() - (10 * S / 14.0) + line_height;
int popup_width = std::max((int)td.size().width(), fm.width(service_name)) + S;
int popup_width = std::max((int)td.size().width(), QFontMetrics_horizontalAdvance(fm, service_name)) + S;
int popup_height = td.size().height() + line_height*2;
while (popup_x + popup_width > _max_width)
popup_x -= S;

View file

@ -172,7 +172,7 @@ QSize BWListDelegate::sizeHint(const QStyleOptionViewItem & option/*option*/, co
float FS = QFontMetricsF(option.font).height();
//float fact = FS/14.0 ;
float w = QFontMetricsF(option.font).width(index.data(Qt::DisplayRole).toString());
float w = QFontMetrics_horizontalAdvance(QFontMetricsF(option.font), index.data(Qt::DisplayRole).toString());
return QSize(w,FS*1.2);
//return QSize(50*fact,17*fact);

View file

@ -45,6 +45,7 @@
#include "util/DateTime.h"
#include "util/RsQtVersion.h"
#include "util/misc.h"
#include "util/RsQtVersion.h"
#define COL_ID 0
#define COL_NICKNAME 1
@ -275,7 +276,7 @@ void GlobalRouterStatisticsWidget::updateContent()
QFontMetricsF fm_monospace(monospace_f) ;
QFontMetricsF fm_times(times_f) ;
static const int cellx = fm_monospace.width(QString(" ")) ;
static const int cellx = QFontMetrics_horizontalAdvance(fm_monospace, QString(" ")) ;
static const int celly = fm_monospace.height() ;
maxHeight = 500*fact ;
@ -316,11 +317,11 @@ void GlobalRouterStatisticsWidget::updateContent()
for(int i=0;i<100*fact;++i)
{
painter.setPen(colorScale(i/100.0/fact)) ;
painter.drawLine(ox+fm_times.width(Q)+i,oy+fm_times.height()*0.5,ox+fm_times.width(Q)+i,oy+fm_times.height()) ;
painter.drawLine(ox+QFontMetrics_horizontalAdvance(fm_times, Q)+i,oy+fm_times.height()*0.5,ox+QFontMetrics_horizontalAdvance(fm_times, Q)+i,oy+fm_times.height()) ;
}
painter.setPen(QColor::fromRgb(0,0,0)) ;
painter.drawText(ox+fm_times.width(Q) + 102*fact,oy+celly,")") ;
painter.drawText(ox+QFontMetrics_horizontalAdvance(fm_times, Q) + 102*fact,oy+celly,")") ;
oy += celly ;
oy += celly ;
@ -370,21 +371,21 @@ void GlobalRouterStatisticsWidget::updateContent()
painter.drawText(ox+2*cellx,oy+celly,ids) ;
for(uint32_t i=0;i<matrix_info.friend_ids.size();++i)
painter.fillRect(ox+i*cellx+fm_monospace.width(ids),oy+0.15*celly,cellx,celly,colorScale(it->second[i])) ;
painter.fillRect(ox+i*cellx+QFontMetrics_horizontalAdvance(fm_monospace, ids),oy+0.15*celly,cellx,celly,colorScale(it->second[i])) ;
if(n == mCurrentN)
{
current_probs = it->second ;
current_oy = oy ;
current_id = it->first ;
current_width = ox+matrix_info.friend_ids.size()*cellx+fm_monospace.width(ids);
current_width = ox+matrix_info.friend_ids.size()*cellx+QFontMetrics_horizontalAdvance(fm_monospace, ids);
}
oy += celly ;
//}
}
mMaxWheelZoneX = ox+matrix_info.friend_ids.size()*cellx + fm_monospace.width(ids);
mMaxWheelZoneX = ox+matrix_info.friend_ids.size()*cellx + QFontMetrics_horizontalAdvance(fm_monospace, ids);
RsIdentityDetails iddetails ;
if(rsIdentity->getIdDetails(current_id,iddetails))
@ -397,14 +398,14 @@ void GlobalRouterStatisticsWidget::updateContent()
painter.setPen(QColor::fromRgb(0,0,0)) ;
painter.setPen(QColor::fromRgb(127,127,127));
painter.drawRect(ox+2*cellx,current_oy+0.15*celly,fm_monospace.width(ids)+cellx*matrix_info.friend_ids.size()- 2*cellx,celly) ;
painter.drawRect(ox+2*cellx,current_oy+0.15*celly,QFontMetrics_horizontalAdvance(fm_monospace, ids)+cellx*matrix_info.friend_ids.size()- 2*cellx,celly) ;
float total_length = (matrix_info.friend_ids.size()+2)*cellx ;
if(!current_probs.empty())
for(uint32_t i=0;i<matrix_info.friend_ids.size();++i)
{
float x1 = ox+(i+0.5)*cellx+fm_monospace.width(ids) ;
float x1 = ox+(i+0.5)*cellx+QFontMetrics_horizontalAdvance(fm_monospace, ids) ;
float y1 = oy+0.15*celly ;
float y2 = y1+(matrix_info.friend_ids.size()-1-i+1)*celly;

View file

@ -269,7 +269,7 @@ void GxsIdStatisticsWidget::updateContent()
QFontMetricsF fm_monospace(monospace_f) ;
QFontMetricsF fm_times(times_f) ;
int cellx = fm_monospace.width(QString(" ")) ;
int cellx = QFontMetrics_horizontalAdvance(fm_monospace, QString(" ")) ;
int celly = fm_monospace.height() ;
// Display general statistics
@ -336,13 +336,13 @@ void GxsIdStatisticsWidget::updateContent()
for(size_t i=0;i<mPublishDateHist.entries().size();++i)
{
QString txt = QString::number(i);
painter.drawText(ox+4*cellx+i*2*cellx+cellx*1.5 - 0.5*fm_times.width(txt),oy+celly,txt);
painter.drawText(ox+4*cellx+i*2*cellx+cellx*1.5 - 0.5*QFontMetrics_horizontalAdvance(fm_times, txt),oy+celly,txt);
}
for(int i=0;i<5;++i)
{
QString txt = QString::number((int)rint(max_entry*i/5.0));
painter.drawText(ox + 4*cellx - cellx - fm_times.width(txt),oy - i*hist_height/5.0 * celly,txt );
painter.drawText(ox + 4*cellx - cellx - QFontMetrics_horizontalAdvance(fm_times, txt),oy - i*hist_height/5.0 * celly,txt );
}
oy += 2*celly;
@ -374,13 +374,13 @@ void GxsIdStatisticsWidget::updateContent()
for(size_t i=0;i<mLastUsedHist.entries().size();++i)
{
QString txt = QString::number(i);
painter.drawText(ox+4*cellx+i*2*cellx+cellx*1.5 - 0.5*fm_times.width(txt),oy+celly,txt);
painter.drawText(ox+4*cellx+i*2*cellx+cellx*1.5 - 0.5*QFontMetrics_horizontalAdvance(fm_times, txt),oy+celly,txt);
}
for(int i=0;i<5;++i)
{
QString txt = QString::number((int)rint(max_entry*i/5.0));
painter.drawText(ox + 4*cellx - cellx - fm_times.width(txt),oy - i*hist_height/5.0 * celly,txt );
painter.drawText(ox + 4*cellx - cellx - QFontMetrics_horizontalAdvance(fm_times, txt),oy - i*hist_height/5.0 * celly,txt );
}
oy += 2*celly;

View file

@ -59,6 +59,7 @@ CrashStackTrace gCrashStackTrace;
#include "util/rsdir.h"
#include "util/rstime.h"
#include "retroshare/rsinit.h"
#include "util/RsQtVersion.h"
#ifdef MESSENGER_WINDOW
#include "gui/MessengerWindow.h"
@ -136,7 +137,7 @@ static void showHelp(const argstream& as)
box.setWindowTitle(QObject::tr("Retroshare commandline arguments"));
// now compute the size of text and set the size of the box. For the record, this doesn't work...
box.setBaseSize( QSize(QFontMetricsF(font).width(text),QFontMetricsF(font).height()*text.count('\n')) );
box.setBaseSize( QSize(QFontMetrics_horizontalAdvance(QFontMetricsF(font), text),QFontMetricsF(font).height()*text.count('\n')) );
box.exec();
}

View file

@ -24,6 +24,8 @@
#include <QPainter>
#include <QMouseEvent>
#include "util/RsQtVersion.h"
RetroStyleLabel::RetroStyleLabel(QWidget * parent, Mode mode, Qt::AlignmentFlag hAlign)
: QLabel(parent), _mode(mode) {
@ -206,7 +208,7 @@ void RetroStyleLabel::mouseReleaseEvent(QMouseEvent * event) {
void RetroStyleLabel::setText(const QString & text) {
QLabel::setText(text);
QFontMetrics fm(font());
int textWidth = fm.width(text);
int textWidth = QFontMetrics_horizontalAdvance(fm, text);
textWidth += 40;
QSize s = size();
if (textWidth > s.width()) {

View file

@ -55,4 +55,10 @@
#define QSortFilterProxyModel_setFilterRegularExpression(proxyModel, pattern) proxyModel->setFilterRegExp(pattern);
#endif
#if QT_VERSION >= QT_VERSION_CHECK (6, 0, 0)
#define QFontMetrics_horizontalAdvance(fontMetrics, text) fontMetrics.horizontalAdvance(text)
#else
#define QFontMetrics_horizontalAdvance(fontMetrics, text) fontMetrics.width(text)
#endif
#endif