计算圆,椭圆的面积(动态方法)

时间:2019-06-21 11:41:06

标签: c++ qt

我实时绘制一个圆,并且我想通过每次通过光标更改形状时计算像素数来计算此(圆椭圆)的面积

label.h

<div class='nested-fields form_group'>
        <%= f.input :first_name, id: 'visfirst', label: 'Firstname' %>
        <%= f.input :last_name, id: 'vislast', label: 'Lastname' %>
        <%= link_to_remove_association 'Remove Visitor', f, class:  'btn btn-warning remov' %>
</div>

part of the Gemfile

gem 'country_select', '~> 3.1', '>= 3.1.1'
gem 'gritter', '~> 1.2'
gem 'axlsx', '~> 2.0', '>= 2.0.1'
gem 'axlsx_rails', '~> 0.5.1'
gem 'cocoon', '~> 1.2', '>= 1.2.10'
gem 'countries'

1 个答案:

答案 0 :(得分:4)

QPainter::drawEllipse将绘制适合给定QRect的椭圆。

QRect的大小以像素为单位。因此,您可以使用经典公式来计算椭圆的面积:

long areaInPixel = M_PI * rect.width()/2 * rect.height()/2