Qt获取屏幕大小和获取可用屏幕大小

QDesktopWidget* desktopWidget = QApplication::desktop();
//获取设备屏幕大小
QRect screenRect = desktopWidget->screenGeometry();
double screenX = screenRect.width();
double screenY = screenRect.height();
//QMessageBox输出double型数值
QMessageBox::information(this, QWidget::tr(“Info”), “ScreenX:” + QString::number(screenX, ‘g’, 6));
QMessageBox::information(this, QWidget::tr(“Info”), “ScreenY:” + QString::number(screenY, ‘g’, 6));

//获取可用桌面大小
QRect deskRect = desktopWidget->availableGeometry();
double availableScreenX = deskRect.width();
double availableScreenY = deskRect.height();
QMessageBox::information(this, QWidget::tr("Info"), "availableScreenX:" + QString::number(availableScreenX, 'g', 6));
QMessageBox::information(this, QWidget::tr("Info"), "availableScreenY:" + QString::number(availableScreenY, 'g', 6));

你可能感兴趣的:(Qt特定功能实现,qt,前端)