How to change the position of DrawLine according to the size of the widget
Unsolved
General and Desktop
-
void wCtrl_Indicator::drawTicks(QPainter* painter) { QBrush brushActive(QColor(58,62,64)); QPen pen(QBrush(brushActive), 2); pen.setCapStyle(Qt::FlatCap); painter->setPen(pen); QPoint c = this->rect().center(); painter->translate(c); painter->rotate(-90); for (int s = 0; s <= THICKS_STEP; s++) { painter->drawLine(15, 0, 25, 0); painter->rotate(360 / THICKS_STEP); } } void wCtrl_Indicator::drawBackGround(QPainter* painter) { QPoint center = this->rect().center(); QRect drawingRect( center.x()-20 , center.y()-20 , this->size().height() * 50 / 100, this->size().height() * 50 / 100); QBrush brushBackgnd(QColor(82, 95, 99)); QPen pen(QBrush(brushBackgnd), PROGRESS_THINKNESS); pen.setCapStyle(Qt::FlatCap); painter->setPen(pen); painter->setBrush(brushBackgnd); painter->drawArc(drawingRect, 90 * 16, ConvertAngle(m_nMax) * 16); } void wCtrl_Indicator::drawProgress(QPainter* painter) { QPoint center = this->rect().center(); QRect drawingRect( center.x() - 20, center.y() - 20, this->size().height() * 50 / 100, this->size().height() * 50 / 100); QBrush brushBackgnd(QColor(75, 147, 191)); QPen pen(QBrush(brushBackgnd), PROGRESS_THINKNESS); pen.setCapStyle(Qt::FlatCap); painter->setPen(pen); painter->setBrush(brushBackgnd); painter->drawArc(drawingRect, (m_dTransAngle--)* 16, 45 * 16); }
I made this widget, but if I change the size of the drawarc, the drawline should also be changed to match the size of the drawarc, but that's not possible.
Is there a way to automatically calculate the size?