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ƶ --- src/gui/doc/snippets/droprectangle/window.cpp | 50 ++++++--------------------- 1 file changed, 10 insertions(+), 40 deletions(-) (limited to 'src/gui/doc/snippets/droprectangle/window.cpp') diff --git a/src/gui/doc/snippets/droprectangle/window.cpp b/src/gui/doc/snippets/droprectangle/window.cpp index 47b66931eab..7b71d4b5084 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 -- cgit v1.2.3