voidDisplay::resizeEvent(QResizeEvent*event)
{
setWidgetSize();
QWidget::resizeEvent(event);
}
voidDisplay::setWidgetSize()
{
intwidgetWidth=this->width();
intwidgetHeight=this->height();
inttempWidth=widgetWidth;
inttempHeight=tempWidth*this->mHeight/this->mWidth;
if (tempHeight>widgetHeight) {
tempHeight=widgetHeight;
tempWidth=tempHeight*this->mWidth/this->mHeight;
}
if (tempWidth>=widgetWidth-1&&tempWidth<=widgetWidth+1&&tempHeight>=widgetHeight-1&&tempHeight<=widgetHeight+1)
return;
mVideo->setGeometry((widgetWidth-tempWidth) /2, (widgetHeight-tempHeight) /2, tempWidth, tempHeight);
}
voidDisplay::setNewSize(intwidth, intheight)
{
mWidth=width;
mHeight=height;
setWidgetSize();
}
QWidget*Display::getVideo()
{
returnmVideo;
}