Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. The startangle value of drawArc is slightly off center.
Forum Updated to NodeBB v4.3 + New Features

The startangle value of drawArc is slightly off center.

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 219 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    IknowQT
    wrote on last edited by IknowQT
    #1

    a201d1b9-25be-4012-9736-0b6d7a397fdc-image.png

    void CustomIndicator::drawProgress(QPainter* painter)
    {
    	painter->save();
    	{
    		QPoint	center = this->rect().center();
    		QRect	drawingRect(
    			center.x() - m_nOffsetCenter,
    			center.y() - m_nOffsetCenter,
    			this->size().height() * 60 / 100,
    			this->size().height() * 60 / 100);
    
    
    		QBrush	brushBackgnd(m_ClrAnm);
    		if (m_eStatus == CustomIndicator::INDICATOR_STATUS::ING)
    		{
    			brushBackgnd.setColor(m_ClrProgress);
    			if (!m_pTimer->isActive())
    				brushBackgnd.setColor(m_ClrBackground);
    		}
    		else
    			brushBackgnd.setColor(m_ClrProgress);
    
    		QPen	pen(QBrush(brushBackgnd), m_nThinkness);
    		painter->setPen(pen);
    		painter->setBrush(brushBackgnd);
    
    		int nAngle = m_eStatus == CustomIndicator::INDICATOR_STATUS::ING || m_eStatus == CustomIndicator::INDICATOR_STATUS::STOP ? -45 * 16 : 360 * 16;
    
    		if (m_eStatus == CustomIndicator::INDICATOR_STATUS::GENERAL)
    			painter->drawArc(drawingRect, 90 * 16, m_rCurAngle * 16);
    		else
    			painter->drawArc(drawingRect, (m_rCurAngle--) * 16, nAngle);
    	}
    	
    	painter->restore();
    }
    

    2dc986c1-a394-4397-890f-314e8e6b9a91-image.png
    I set the startangle to 90 degrees and ran it.
    The starting position is not in the center and there is some offset
    What is wrong?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mchinand
      wrote on last edited by mchinand
      #2

      Could be due to the pen's CapStyle. Try setting it to Qt::FlatCap.

      I 1 Reply Last reply
      0
      • M mchinand

        Could be due to the pen's CapStyle. Try setting it to Qt::FlatCap.

        I Offline
        I Offline
        IknowQT
        wrote on last edited by
        #3

        @mchinand

        I think you're right. thank you.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved