TechDraw: fix "%.0w" format spec (#25367)

This commit is contained in:
Florian Foinant-Willig
2025-11-16 19:51:28 +01:00
committed by GitHub
parent a77f96ea86
commit 526f7f2550

View File

@@ -298,15 +298,17 @@ QString DimensionFormatter::formatValueToSpec(const double value, QString format
if (spec == QStringLiteral("w")) {
formattedValue = format(QStringLiteral("%") + dec + QStringLiteral("f"), value);
// First, cut trailing zeros
while(formattedValue.endsWith(QStringLiteral("0")))
{
formattedValue.chop(1);
}
// Second, try to cut also decimal dot
if(formattedValue.endsWith(QStringLiteral(".")))
{
formattedValue.chop(1);
if (formattedValue.contains(QStringLiteral("."))){
// First, cut trailing zeros
while(formattedValue.endsWith(QStringLiteral("0")))
{
formattedValue.chop(1);
}
// Second, try to cut also decimal dot
if(formattedValue.endsWith(QStringLiteral(".")))
{
formattedValue.chop(1);
}
}
}
else if (spec == QStringLiteral("r")) {