Doc: compile droprectangle snippets

Done-with: Nico Vertriest <nico.vertriest@qt.io>
Task-number: QTBUG-81486
Change-Id: I0087f7cc0746168bc2223972074fed468c3fba46
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
This commit is contained in:
Paul Wicking 2020-08-31 14:01:31 +02:00
parent 4dd53a40aa
commit 65fb72d302
3 changed files with 17 additions and 43 deletions

View File

@ -1,3 +1,6 @@
HEADERS = window.h
SOURCES = main.cpp \
window.cpp
TEMPLATE = lib
TARGET = droprectangle_snippets
QT += core gui widgets
SOURCES = \
window.cpp

View File

@ -47,44 +47,20 @@
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QDragMoveEvent>
#include <QFrame>
#include <QMimeData>
#include <QWidget>
#include <QtGui>
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);
void dragMoveEvent(QDragMoveEvent *event);
QLabel *mimeTypeLabel = new QLabel(tr("MIME types:"), this);
mimeTypeCombo = new QComboBox(this);
QFrame *dropFrame = nullptr;
};
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);
QHBoxLayout *dropLayout = new QHBoxLayout;
dropLayout->addStretch(0);
dropLayout->addWidget(dropFrame);
dropLayout->addStretch(0);
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

View File

@ -9,6 +9,7 @@ contains(QT_BUILD_PARTS, tests) {
draganddrop \
droparea \
dropevents \
droprectangle \
qfontdatabase \
textblock-formats \
textblock-fragments \