From 65fb72d3026d476371a2c4006dac47bc9ce57b1a Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Mon, 31 Aug 2020 14:01:31 +0200 Subject: Doc: compile droprectangle snippets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Done-with: Nico Vertriest Task-number: QTBUG-81486 Change-Id: I0087f7cc0746168bc2223972074fed468c3fba46 Reviewed-by: Topi Reiniƶ --- .../doc/snippets/droprectangle/droprectangle.pro | 9 ++-- src/gui/doc/snippets/droprectangle/window.cpp | 50 +++++----------------- src/gui/doc/snippets/snippets.pro | 1 + 3 files changed, 17 insertions(+), 43 deletions(-) (limited to 'src/gui/doc') diff --git a/src/gui/doc/snippets/droprectangle/droprectangle.pro b/src/gui/doc/snippets/droprectangle/droprectangle.pro index 6283406f25..c8ed4d3694 100644 --- a/src/gui/doc/snippets/droprectangle/droprectangle.pro +++ b/src/gui/doc/snippets/droprectangle/droprectangle.pro @@ -1,3 +1,6 @@ -HEADERS = window.h -SOURCES = main.cpp \ - window.cpp +TEMPLATE = lib +TARGET = droprectangle_snippets +QT += core gui widgets + +SOURCES = \ + window.cpp diff --git a/src/gui/doc/snippets/droprectangle/window.cpp b/src/gui/doc/snippets/droprectangle/window.cpp index 47b66931ea..7b71d4b508 100644 --- a/src/gui/doc/snippets/droprectangle/window.cpp +++ b/src/gui/doc/snippets/droprectangle/window.cpp @@ -47,44 +47,20 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include +#include +#include +#include -#include +namespace droprectangle { -#include "window.h" - -Window::Window(QWidget *parent) - : QWidget(parent) +struct Window : public QWidget { - QLabel *textLabel = new QLabel(tr("Data:"), this); - textBrowser = new QTextBrowser(this); - - QLabel *mimeTypeLabel = new QLabel(tr("MIME types:"), this); - mimeTypeCombo = new QComboBox(this); - - dropFrame = new QFrame(this); - dropFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); - QLabel *dropLabel = new QLabel(tr("Drop items here"), dropFrame); - dropLabel->setAlignment(Qt::AlignHCenter); - - QVBoxLayout *dropFrameLayout = new QVBoxLayout(dropFrame); - dropFrameLayout->addWidget(dropLabel); + void dragMoveEvent(QDragMoveEvent *event); - QHBoxLayout *dropLayout = new QHBoxLayout; - dropLayout->addStretch(0); - dropLayout->addWidget(dropFrame); - dropLayout->addStretch(0); + QFrame *dropFrame = nullptr; +}; - QVBoxLayout *mainLayout = new QVBoxLayout(this); - mainLayout->addWidget(textLabel); - mainLayout->addWidget(textBrowser); - mainLayout->addWidget(mimeTypeLabel); - mainLayout->addWidget(mimeTypeCombo); - mainLayout->addSpacing(32); - mainLayout->addLayout(dropLayout); - - setAcceptDrops(true); - setWindowTitle(tr("Drop Rectangle")); -} //! [0] void Window::dragMoveEvent(QDragMoveEvent *event) @@ -96,11 +72,5 @@ void Window::dragMoveEvent(QDragMoveEvent *event) } //! [0] -void Window::dropEvent(QDropEvent *event) -{ - textBrowser->setPlainText(event->mimeData()->text()); - mimeTypeCombo->clear(); - mimeTypeCombo->addItems(event->mimeData()->formats()); - event->acceptProposedAction(); -} +} // droprectangle diff --git a/src/gui/doc/snippets/snippets.pro b/src/gui/doc/snippets/snippets.pro index ce8ccd1577..d0a619c7e3 100644 --- a/src/gui/doc/snippets/snippets.pro +++ b/src/gui/doc/snippets/snippets.pro @@ -9,6 +9,7 @@ contains(QT_BUILD_PARTS, tests) { draganddrop \ droparea \ dropevents \ + droprectangle \ qfontdatabase \ textblock-formats \ textblock-fragments \ -- cgit v1.2.3