窗口居中

This commit is contained in:
rankun 2018-11-08 18:59:13 +08:00
parent 4c873b98e7
commit 8affa1937d
2 changed files with 17 additions and 9 deletions

View file

@ -77,16 +77,23 @@ VideoForm::~VideoForm()
void VideoForm::updateShowSize(const QSize &newSize)
{
QSize showSize = newSize;
QDesktopWidget* desktop = QApplication::desktop();
if (desktop) {
QSize screenSize = desktop->size();
showSize.setWidth(qMin(newSize.width(), screenSize.width()));
showSize.setHeight(qMin(newSize.height(), screenSize.height() - 100));
}
if (frameSize != newSize) {
frameSize = newSize;
if (showSize != size()) {
resize(showSize);
QSize showSize = newSize;
QDesktopWidget* desktop = QApplication::desktop();
if (desktop) {
QRect screenRect = desktop->availableGeometry();
showSize.setWidth(qMin(newSize.width(), screenRect.width()));
showSize.setHeight(qMin(newSize.height(), screenRect.height() - 100));
// 窗口居中
move(screenRect.center() - geometry().center());
}
if (showSize != size()) {
resize(showSize);
}
}
}

View file

@ -33,6 +33,7 @@ protected:
private:
Ui::videoForm *ui;
QSize frameSize;
Server* m_server = Q_NULLPTR;
Decoder m_decoder;
Frames m_frames;