1 72 142 142 143 21
QFont font("times", 10); QFontMetrics fm(font); int pixelsWide = 0; int pixelsHigh = fm.height();
Repeater { id: repeaterValueText model: pelData.gaugeDataModel anchors.fill: parent delegate: Label { height: 20 width: model.eMaxPixelSizeOfTextValue color: model.eValueTextColor text: model.eScaleValue font.pixelSize: model.eValueTextSize antialiasing: true horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter x: model.eValueTextCenterX - model.eCenterTextValueRect.x y: model.eValueTextCenterY - model.eCenterTextValueRect.y } }
Repeater { id: repeaterValueText model: root.pelData.gaugeDataModel anchors.fill: parent delegate: Item { id: delegateItem implicitHeight: childrenRect.height implicitWidth: delegateItem.eWidth required property point eStartPoint required property point eEndPoint required property real eWidth required property color eColorTickMark required property string eScaleValue required property color eValueTextColor required property real eValueTextCenterX required property real eValueTextCenterY required property real eValueTextSize required property int eMaxPixelsWidthText required property int eMaxPixelsHeightText required property point eCenterTextValueRect Text { id: labelTextValue height: delegateItem.eMaxPixelsHeightText width: delegateItem.eMaxPixelsWidthText color: delegateItem.eValueTextColor text: delegateItem.eScaleValue font.pixelSize: delegateItem.eValueTextSize antialiasing: true horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter x: delegateItem.eValueTextCenterX - delegateItem.eCenterTextValueRect.x y: delegateItem.eValueTextCenterY - delegateItem.eCenterTextValueRect.y } } }
QFontMetrics fm(m_FontText); int pixelsWide = 0; int pixelsHigh = fm.height(); pixelsWide = fm.horizontalAdvance(str); if (m_MaxPixelsWidthText < pixelsWide) { m_MaxPixelsWidthText = pixelsWide; } m_MaxPixelsHeightText = pixelsHigh;