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
src_corelib_kernel_qmimedata.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#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
5
7void MyWidget::dragEnterEvent(QDragEnterEvent *event)
8{
9 if (event->mimeData()->hasUrls())
10 event->acceptProposedAction();
11}
12
13void MyWidget::dropEvent(QDropEvent *event)
14{
15 if (event->mimeData()->hasUrls()) {
16 foreach (QUrl url, event->mimeData()->urls()) {
17 ...
18 }
19 }
20}
22
23
26
28mimeData->setData("text/csv", csvData);
30
31
33void MyWidget::dropEvent(QDropEvent *event)
34{
35 const MyMimeData *myData =
36 qobject_cast<const MyMimeData *>(event->mimeData());
37 if (myData) {
38 // access myData's data directly (not through QMimeData's API)
39 }
40}
42
43
45application/x-qt-windows-mime;value="<custom type>"
47
48
50application/x-qt-windows-mime;value="FileGroupDescriptor"
51application/x-qt-windows-mime;value="FileContents"
53
54
56if (event->mimeData()->hasImage()) {
57 QImage image = qvariant_cast<QImage>(event->mimeData()->imageData());
58 ...
59}
61
62
64mimeData->setImageData(QImage("beautifulfjord.png"));
66
67
69if (event->mimeData()->hasColor()) {
70 QColor color = qvariant_cast<QColor>(event->mimeData()->colorData());
71 ...
72}
74
75
77application/x-qt-windows-mime;value="FileContents";index=0
78application/x-qt-windows-mime;value="FileContents";index=1
\inmodule QtCore
Definition qbytearray.h:57
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtGui
Definition qimage.h:37
\inmodule QtCore
Definition qmimedata.h:16
void setData(const QString &mimetype, const QByteArray &data)
Sets the data associated with the MIME type given by mimeType to the specified data.
void setImageData(const QVariant &image)
Sets the data in the object to the given image.
\inmodule QtCore
Definition qurl.h:94
Definition image.cpp:4
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLint GLint GLint GLint GLint x
[0]
GLuint index
[2]
GLuint color
[2]
struct _cl_event * event
QUrl url("example.com")
[constructor-url-reference]
application x qt windows mime
[2]
QMimeData * mimeData
QByteArray csvData
[0]