Created
December 10, 2013 08:03
-
-
Save liangqi/7887139 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From ed8d1074f0fe8fb51aa1e42709cf7700f2e3d8af Mon Sep 17 00:00:00 2001 | |
| From: Qt <qt@Supers-iMac-2.local> | |
| Date: Tue, 10 Dec 2013 09:01:37 +0100 | |
| Subject: [PATCH] fullscreen window version | |
| --- | |
| .../widgets/windowflags/controllerwindow.cpp | 26 +++++++++++++++------ | |
| .../widgets/widgets/windowflags/controllerwindow.h | 3 +++ | |
| .../widgets/widgets/windowflags/previewwindow.cpp | 27 ++++++++-------------- | |
| .../widgets/widgets/windowflags/previewwindow.h | 15 +++--------- | |
| 4 files changed, 34 insertions(+), 37 deletions(-) | |
| diff --git a/examples/widgets/widgets/windowflags/controllerwindow.cpp b/examples/widgets/widgets/windowflags/controllerwindow.cpp | |
| index 64ca795..c06c17e 100644 | |
| --- a/examples/widgets/widgets/windowflags/controllerwindow.cpp | |
| +++ b/examples/widgets/widgets/windowflags/controllerwindow.cpp | |
| @@ -42,19 +42,31 @@ | |
| #include "controllerwindow.h" | |
| +void ControllerWindow::fullscreen() | |
| +{ | |
| + if (fs) | |
| + previewWindow->showNormal(); | |
| + else | |
| + previewWindow->showFullScreen(); | |
| + fs = !fs; | |
| +} | |
| //! [0] | |
| ControllerWindow::ControllerWindow() | |
| { | |
| - previewWindow = new PreviewWindow(this); | |
| + fs = false; | |
| + previewWindow = new PreviewWindow(); | |
| createTypeGroupBox(); | |
| createHintsGroupBox(); | |
| + fullscreenButton = new QPushButton(tr("&FullScreen")); | |
| + connect(fullscreenButton, SIGNAL(clicked()), this, SLOT(fullscreen())); | |
| quitButton = new QPushButton(tr("&Quit")); | |
| connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); | |
| QHBoxLayout *bottomLayout = new QHBoxLayout; | |
| bottomLayout->addStretch(); | |
| + bottomLayout->addWidget(fullscreenButton); | |
| bottomLayout->addWidget(quitButton); | |
| QHBoxLayout *mainLayout = new QHBoxLayout; | |
| @@ -125,12 +137,12 @@ void ControllerWindow::updatePreview() | |
| previewWindow->setWindowFlags(flags); | |
| //! [3] //! [4] | |
| - QPoint pos = previewWindow->pos(); | |
| - if (pos.x() < 0) | |
| - pos.setX(0); | |
| - if (pos.y() < 0) | |
| - pos.setY(0); | |
| - previewWindow->move(pos); | |
| +// QPoint pos = previewWindow->pos(); | |
| +// if (pos.x() < 0) | |
| +// pos.setX(0); | |
| +// if (pos.y() < 0) | |
| +// pos.setY(0); | |
| +// previewWindow->move(pos); | |
| previewWindow->show(); | |
| } | |
| //! [4] | |
| diff --git a/examples/widgets/widgets/windowflags/controllerwindow.h b/examples/widgets/widgets/windowflags/controllerwindow.h | |
| index ad3db9c..a9e8231 100644 | |
| --- a/examples/widgets/widgets/windowflags/controllerwindow.h | |
| +++ b/examples/widgets/widgets/windowflags/controllerwindow.h | |
| @@ -63,6 +63,7 @@ public: | |
| private slots: | |
| void updatePreview(); | |
| + void fullscreen(); | |
| private: | |
| void createTypeGroupBox(); | |
| @@ -74,6 +75,8 @@ private: | |
| QGroupBox *typeGroupBox; | |
| QGroupBox *hintsGroupBox; | |
| + bool fs; | |
| + QPushButton *fullscreenButton; | |
| QPushButton *quitButton; | |
| QRadioButton *windowRadioButton; | |
| diff --git a/examples/widgets/widgets/windowflags/previewwindow.cpp b/examples/widgets/widgets/windowflags/previewwindow.cpp | |
| index 645b6fa..00e5f9a 100644 | |
| --- a/examples/widgets/widgets/windowflags/previewwindow.cpp | |
| +++ b/examples/widgets/widgets/windowflags/previewwindow.cpp | |
| @@ -38,34 +38,25 @@ | |
| ** | |
| ****************************************************************************/ | |
| -#include <QtWidgets> | |
| +#include <QtGui/QWindow> | |
| + | |
| +#include <QtDebug> | |
| #include "previewwindow.h" | |
| //! [0] | |
| -PreviewWindow::PreviewWindow(QWidget *parent) | |
| - : QWidget(parent) | |
| +PreviewWindow::PreviewWindow(QWindow *parent) | |
| + : QWindow(parent) | |
| { | |
| - textEdit = new QTextEdit; | |
| - textEdit->setReadOnly(true); | |
| - textEdit->setLineWrapMode(QTextEdit::NoWrap); | |
| - | |
| - closeButton = new QPushButton(tr("&Close")); | |
| - connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); | |
| - | |
| - QVBoxLayout *layout = new QVBoxLayout; | |
| - layout->addWidget(textEdit); | |
| - layout->addWidget(closeButton); | |
| - setLayout(layout); | |
| - | |
| - setWindowTitle(tr("Preview")); | |
| + //setWindowTitle(tr("Preview")); | |
| } | |
| //! [0] | |
| //! [1] | |
| void PreviewWindow::setWindowFlags(Qt::WindowFlags flags) | |
| { | |
| - QWidget::setWindowFlags(flags); | |
| + flags &= ~Qt::WindowFullscreenButtonHint; | |
| + QWindow::setFlags(flags); | |
| QString text; | |
| @@ -115,6 +106,6 @@ void PreviewWindow::setWindowFlags(Qt::WindowFlags flags) | |
| if (flags & Qt::CustomizeWindowHint) | |
| text += "\n| Qt::CustomizeWindowHint"; | |
| - textEdit->setPlainText(text); | |
| + qDebug() << "text:" << text; | |
| } | |
| //! [1] | |
| diff --git a/examples/widgets/widgets/windowflags/previewwindow.h b/examples/widgets/widgets/windowflags/previewwindow.h | |
| index a82d0fa..672284a 100644 | |
| --- a/examples/widgets/widgets/windowflags/previewwindow.h | |
| +++ b/examples/widgets/widgets/windowflags/previewwindow.h | |
| @@ -41,26 +41,17 @@ | |
| #ifndef PREVIEWWINDOW_H | |
| #define PREVIEWWINDOW_H | |
| -#include <QWidget> | |
| - | |
| -QT_BEGIN_NAMESPACE | |
| -class QPushButton; | |
| -class QTextEdit; | |
| -QT_END_NAMESPACE | |
| +#include <QtGui/QWindow> | |
| //! [0] | |
| -class PreviewWindow : public QWidget | |
| +class PreviewWindow : public QWindow | |
| { | |
| Q_OBJECT | |
| public: | |
| - PreviewWindow(QWidget *parent = 0); | |
| + PreviewWindow(QWindow *parent = 0); | |
| void setWindowFlags(Qt::WindowFlags flags); | |
| - | |
| -private: | |
| - QTextEdit *textEdit; | |
| - QPushButton *closeButton; | |
| }; | |
| //! [0] | |
| -- | |
| 1.7.12.4 (Apple Git-37) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment