• 4328阅读
  • 0回复

QPainter::setViewport 到底做了什么变换 [复制链接]

上一主题 下一主题
离线cibiren
 

只看楼主 倒序阅读 楼主  发表于: 2012-01-31
qt助手里面这样写道:
void QPainter::setViewport ( int x, int y, int width, int height )
Sets the painter's viewport rectangle to the given rectangle, and enables view transformations.
The viewport rectangle is part of the view transformation. The viewport specifies the device coordinate system.
The default viewport rectangle is the same as the device's rectangle.

请问:setViewport 到底做了什么变换,
void Widget::paintEvent(QPaintEvent * /* event */)
{
    QPainter painter(this);    
    painter.setViewport(0, 0, 200, 200);
    painter.drawLine(0,0,200,200);
}
线段的终点在哪个像素坐标上?
当Widget 大小是400X400像素时,线段终点在 点(100,100)处。怎么搞的,如何计算的?


快速回复
限100 字节
 
上一个 下一个