diff options
Diffstat (limited to 'examples/quick/quickwidgets')
4 files changed, 46 insertions, 9 deletions
diff --git a/examples/quick/quickwidgets/qquickviewcomparison/main.cpp b/examples/quick/quickwidgets/qquickviewcomparison/main.cpp index a80d151401..73db97eddb 100644 --- a/examples/quick/quickwidgets/qquickviewcomparison/main.cpp +++ b/examples/quick/quickwidgets/qquickviewcomparison/main.cpp @@ -49,6 +49,8 @@ ****************************************************************************/ #include <QApplication> +#include <QCommandLineParser> +#include <QCommandLineOption> #include "mainwindow.h" @@ -58,8 +60,22 @@ int main(int argc, char **argv) QApplication app(argc, argv); - bool transparency = QCoreApplication::arguments().contains(QStringLiteral("--transparent")); - MainWindow widgetWindow(transparency); + QCoreApplication::setApplicationName("Qt QQuickView/QQuickWidget Comparison Example"); + QCoreApplication::setOrganizationName("QtProject"); + QCoreApplication::setApplicationVersion(QT_VERSION_STR); + QCommandLineParser parser; + parser.setApplicationDescription(QCoreApplication::applicationName()); + parser.addHelpOption(); + parser.addVersionOption(); + QCommandLineOption noRenderAlphaOption("no-render-alpha", "Do not render Alpha"); + parser.addOption(noRenderAlphaOption); + QCommandLineOption transparentOption("transparent", "Transparent window"); + parser.addOption(transparentOption); + + parser.process(app); + + const bool transparency = parser.isSet(transparentOption); + MainWindow widgetWindow(transparency, parser.isSet(noRenderAlphaOption)); if (transparency) { widgetWindow.setAttribute(Qt::WA_TranslucentBackground); widgetWindow.setAttribute(Qt::WA_NoSystemBackground, false); diff --git a/examples/quick/quickwidgets/qquickviewcomparison/mainwindow.cpp b/examples/quick/quickwidgets/qquickviewcomparison/mainwindow.cpp index e2892640f7..524af1e915 100644 --- a/examples/quick/quickwidgets/qquickviewcomparison/mainwindow.cpp +++ b/examples/quick/quickwidgets/qquickviewcomparison/mainwindow.cpp @@ -50,7 +50,6 @@ #include "mainwindow.h" #include "fbitem.h" -#include <QCoreApplication> #include <QVBoxLayout> #include <QGroupBox> #include <QRadioButton> @@ -58,10 +57,11 @@ #include <QLabel> #include <QQuickItem> -MainWindow::MainWindow(bool transparency) +MainWindow::MainWindow(bool transparency, bool noRenderAlpha) : m_currentView(0), m_currentRootObject(0), - m_transparent(transparency) + m_transparent(transparency), + m_noRenderAlpha(noRenderAlpha) { QVBoxLayout *layout = new QVBoxLayout; @@ -188,7 +188,7 @@ void MainWindow::updateView() if (m_currentRootObject) { m_currentRootObject->setProperty("currentText", text); m_currentRootObject->setProperty("multisample", m_checkboxMultiSample->isChecked()); - if (!QCoreApplication::arguments().contains(QStringLiteral("--no_render_alpha"))) + if (!m_noRenderAlpha) m_currentRootObject->setProperty("translucency", m_transparent); } diff --git a/examples/quick/quickwidgets/qquickviewcomparison/mainwindow.h b/examples/quick/quickwidgets/qquickviewcomparison/mainwindow.h index 4358e6769f..d182b70960 100644 --- a/examples/quick/quickwidgets/qquickviewcomparison/mainwindow.h +++ b/examples/quick/quickwidgets/qquickviewcomparison/mainwindow.h @@ -63,7 +63,7 @@ QT_FORWARD_DECLARE_CLASS(QLayout) class MainWindow : public QWidget { public: - MainWindow(bool transparency); + explicit MainWindow(bool transparency, bool noRenderAlpha); protected: void resizeEvent(QResizeEvent*); @@ -96,6 +96,7 @@ private: QSurfaceFormat m_format; bool m_transparent; + bool m_noRenderAlpha; }; #endif diff --git a/examples/quick/quickwidgets/quickwidget/main.cpp b/examples/quick/quickwidgets/quickwidget/main.cpp index 382744ca93..c54586c5de 100644 --- a/examples/quick/quickwidgets/quickwidget/main.cpp +++ b/examples/quick/quickwidgets/quickwidget/main.cpp @@ -54,6 +54,9 @@ #include <QtWidgets> #include "fbitem.h" +static bool optMultipleSample = false; +static bool optCoreProfile = false; + class MainWindow : public QMainWindow { Q_OBJECT public: @@ -75,11 +78,11 @@ MainWindow::MainWindow() : m_quickWidget(new QQuickWidget) { QSurfaceFormat format; - if (QCoreApplication::arguments().contains(QStringLiteral("--coreprofile"))) { + if (optCoreProfile) { format.setVersion(4, 4); format.setProfile(QSurfaceFormat::CoreProfile); } - if (QCoreApplication::arguments().contains(QStringLiteral("--multisample"))) + if (optMultipleSample) format.setSamples(4); m_quickWidget->setFormat(format); @@ -194,6 +197,23 @@ int main(int argc, char **argv) { QApplication app(argc, argv); + QCoreApplication::setApplicationName("Qt QQuickWidget 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); + + parser.process(app); + + optMultipleSample = parser.isSet(multipleSampleOption); + optCoreProfile = parser.isSet(coreProfileOption); + qmlRegisterType<FbItem>("QuickWidgetExample", 1, 0, "FbItem"); MainWindow mainWindow; |