Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
mainwindow.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QtWidgets>
5
6#include "dragwidget.h"
7#include "mainwindow.h"
8
10 : QMainWindow(parent)
11{
12 QFrame *centralWidget = new QFrame(this);
13
14 QLabel *mimeTypeLabel = new QLabel(tr("MIME types:"), centralWidget);
15 mimeTypeCombo = new QComboBox(centralWidget);
16
17 QLabel *dataLabel = new QLabel(tr("Amount of data (bytes):"), centralWidget);
18 dragWidget = new DragWidget(centralWidget);
19
20 connect(dragWidget, &DragWidget::mimeTypes,
24
25 QVBoxLayout *mainLayout = new QVBoxLayout(centralWidget);
26 mainLayout->addWidget(mimeTypeLabel);
27 mainLayout->addWidget(mimeTypeCombo);
28 mainLayout->addSpacing(32);
29 mainLayout->addWidget(dataLabel);
30 mainLayout->addWidget(dragWidget);
31
32 statusBar();
33 dragWidget->setData(QString("text/plain"), QByteArray("Hello world"));
35 setWindowTitle(tr("Drag and Drop"));
36}
37
38void MainWindow::setDragResult(const QString &actionText)
39{
40 statusBar()->showMessage(actionText);
41}
42
44{
45 mimeTypeCombo->clear();
46 mimeTypeCombo->addItems(types);
47}
void dragResult(const QString &actionText)
void setData(const QString &mimetype, const QByteArray &newData)
[8]
void mimeTypes(const QStringList &types)
void setDragResult(const QString &actionText)
void setMimeTypes(const QStringList &types)
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment.
void addSpacing(int size)
Adds a non-stretchable space (a QSpacerItem) with size size to the end of this box layout.
The QComboBox widget combines a button with a dropdown list.
Definition qcombobox.h:24
void addItems(const QStringList &texts)
Adds each of the strings in the given texts to the combobox.
Definition qcombobox.h:135
void clear()
Clears the combobox, removing all items.
The QFrame class is the base class of widgets that can have a frame.
Definition qframe.h:17
The QLabel widget provides a text or image display.
Definition qlabel.h:20
The QMainWindow class provides a main application window.
Definition qmainwindow.h:25
QWidget * centralWidget() const
Returns the central widget for the main window.
void setCentralWidget(QWidget *widget)
Sets the given widget to be the main window's central widget.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QVBoxLayout class lines up widgets vertically.
Definition qboxlayout.h:91
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void setWindowTitle(const QString &)
Definition qwidget.cpp:6105
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
GLsizei GLenum GLenum * types
#define tr(X)
statusBar() -> addWidget(new MyReadWriteIndication)
[0]