aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/quickwidgets/qquickwidgetversuswindow_opengl/mainwindow.h
blob: 24d8bf3b3584cb9ea229144057ecb5a79b71094b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QWidget>
#include <QQuickWidget>
#include <QQuickView>

QT_FORWARD_DECLARE_CLASS(QRadioButton)
QT_FORWARD_DECLARE_CLASS(QCheckBox)
QT_FORWARD_DECLARE_CLASS(QLabel)
QT_FORWARD_DECLARE_CLASS(QLayout)

class MainWindow : public QWidget
{
public:
    explicit MainWindow(bool transparency, bool noRenderAlpha);

protected:
    void resizeEvent(QResizeEvent*);

private slots:
    void updateView();
    void onStatusChangedView(QQuickView::Status status);
    void onStatusChangedWidget(QQuickWidget::Status status);
    void onSceneGraphError(QQuickWindow::SceneGraphError error, const QString &message);

private:
    void switchTo(QWidget *view);

    QRadioButton *m_radioView;
    QRadioButton *m_radioWidget;
    QCheckBox *m_checkboxMultiSample;
    QLabel *m_labelStatus;
    QLayout *m_containerLayout;
    QWidget *m_currentView;
    QObject *m_currentRootObject;
    QLabel *m_overlayLabel;
    QCheckBox *m_checkboxOverlayVisible;

    enum State {
        Unknown,
        UseWidget,
        UseWindow
    } m_state;

    QSurfaceFormat m_format;

    bool m_transparent;
    bool m_noRenderAlpha;
};

#endif