mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2024-11-27 06:28:26 +08:00
60 lines
2.0 KiB
C++
60 lines
2.0 KiB
C++
// Copyright (C) 2016 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
|
|
|
#include <QApplication>
|
|
#include <QSurfaceFormat>
|
|
#include <QScreen>
|
|
#include <QCommandLineParser>
|
|
#include <QCommandLineOption>
|
|
|
|
#include "glwidget.h"
|
|
#include "mainwindow.h"
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
QApplication app(argc, argv);
|
|
|
|
QCoreApplication::setApplicationName("Qt Hello GL 2 Example");
|
|
QCoreApplication::setOrganizationName("QtProject");
|
|
QCoreApplication::setApplicationVersion(QT_VERSION_STR);
|
|
QCommandLineParser parser;
|
|
parser.setApplicationDescription(QCoreApplication::applicationName());
|
|
parser.addHelpOption();
|
|
parser.addVersionOption();
|
|
QCommandLineOption multipleSampleOption("multisample", "Multisampling");
|
|
parser.addOption(multipleSampleOption);
|
|
QCommandLineOption coreProfileOption("coreprofile", "Use core profile");
|
|
parser.addOption(coreProfileOption);
|
|
QCommandLineOption transparentOption("transparent", "Transparent window");
|
|
parser.addOption(transparentOption);
|
|
|
|
parser.process(app);
|
|
|
|
QSurfaceFormat fmt;
|
|
fmt.setDepthBufferSize(24);
|
|
if (parser.isSet(multipleSampleOption))
|
|
fmt.setSamples(4);
|
|
if (parser.isSet(coreProfileOption)) {
|
|
fmt.setVersion(3, 2);
|
|
fmt.setProfile(QSurfaceFormat::CoreProfile);
|
|
}
|
|
QSurfaceFormat::setDefaultFormat(fmt);
|
|
|
|
MainWindow mainWindow;
|
|
|
|
GLWidget::setTransparent(parser.isSet(transparentOption));
|
|
if (GLWidget::isTransparent()) {
|
|
mainWindow.setAttribute(Qt::WA_TranslucentBackground);
|
|
mainWindow.setAttribute(Qt::WA_NoSystemBackground, false);
|
|
}
|
|
mainWindow.resize(mainWindow.sizeHint());
|
|
int desktopArea = QGuiApplication::primaryScreen()->size().width() *
|
|
QGuiApplication::primaryScreen()->size().height();
|
|
int widgetArea = mainWindow.width() * mainWindow.height();
|
|
if (((float)widgetArea / (float)desktopArea) < 0.75f)
|
|
mainWindow.show();
|
|
else
|
|
mainWindow.showMaximized();
|
|
return app.exec();
|
|
}
|