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
QMimeData Class Reference

\inmodule QtCore More...

#include <qmimedata.h>

+ Inheritance diagram for QMimeData:
+ Collaboration diagram for QMimeData:

Public Member Functions

 QMimeData ()
 Constructs a new MIME data object with no data in it.
 
 ~QMimeData ()
 Destroys the MIME data object.
 
QList< QUrlurls () const
 Returns a list of URLs contained within the MIME data object.
 
void setUrls (const QList< QUrl > &urls)
 Sets the URLs stored in the MIME data object to those specified by urls.
 
bool hasUrls () const
 Returns true if the object can return a list of urls; otherwise returns false.
 
QString text () const
 Returns a plain text (MIME type text/plain) representation of the data.
 
void setText (const QString &text)
 Sets text as the plain text (MIME type text/plain) used to represent the data.
 
bool hasText () const
 Returns true if the object can return plain text (MIME type text/plain); otherwise returns false.
 
QString html () const
 Returns a string if the data stored in the object is HTML (MIME type text/html); otherwise returns an empty string.
 
void setHtml (const QString &html)
 Sets html as the HTML (MIME type text/html) used to represent the data.
 
bool hasHtml () const
 Returns true if the object can return HTML (MIME type text/html); otherwise returns false.
 
QVariant imageData () const
 Returns a QVariant storing a QImage if the object can return an image; otherwise returns a null variant.
 
void setImageData (const QVariant &image)
 Sets the data in the object to the given image.
 
bool hasImage () const
 Returns true if the object can return an image; otherwise returns false.
 
QVariant colorData () const
 Returns a color if the data stored in the object represents a color (MIME type application/x-color); otherwise returns a null variant.
 
void setColorData (const QVariant &color)
 Sets the color data in the object to the given color.
 
bool hasColor () const
 Returns true if the object can return a color (MIME type application/x-color); otherwise returns false.
 
QByteArray data (const QString &mimetype) const
 Returns the data stored in the object in the format described by the MIME type specified by mimeType.
 
void setData (const QString &mimetype, const QByteArray &data)
 Sets the data associated with the MIME type given by mimeType to the specified data.
 
void removeFormat (const QString &mimetype)
 
virtual bool hasFormat (const QString &mimetype) const
 Returns true if the object can return data for the MIME type specified by mimeType; otherwise returns false.
 
virtual QStringList formats () const
 Returns a list of formats supported by the object.
 
void clear ()
 Removes all the MIME type and data entries in the object.
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 Constructs an object with parent object parent.
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects.
 
virtual bool event (QEvent *event)
 This virtual function receives events to an object and should return true if the event e was recognized and processed.
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 Filters events if this object has been installed as an event filter for the watched object.
 
QString objectName () const
 
Q_WEAK_OVERLOAD void setObjectName (const QString &name)
 Sets the object's name to name.
 
void setObjectName (QAnyStringView name)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false.
 
bool isWindowType () const
 Returns true if the object is a window; otherwise returns false.
 
bool isQuickItemType () const
 Returns true if the object is a QQuickItem; otherwise returns false.
 
bool signalsBlocked () const noexcept
 Returns true if signals are blocked; otherwise returns false.
 
bool blockSignals (bool b) noexcept
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it).
 
QThreadthread () const
 Returns the thread in which the object lives.
 
bool moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL)
 Changes the thread affinity for this object and its children and returns true on success.
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds.
 
int startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 Kills the timer with timer identifier, id.
 
void killTimer (Qt::TimerId id)
 
template<typename T >
findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object.
 
template<typename T >
QList< T > findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
 
template<typename T >
findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename T >
QList< T > findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const QObjectListchildren () const
 Returns a list of child objects.
 
void setParent (QObject *parent)
 Makes the object a child of parent.
 
void installEventFilter (QObject *filterObj)
 Installs an event filter filterObj on this object.
 
void removeEventFilter (QObject *obj)
 Removes an event filter object obj from this object.
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 Dumps a tree of children to the debug output.
 
void dumpObjectInfo () const
 Dumps information about signal connections, etc.
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value.
 
bool setProperty (const char *name, QVariant &&value)
 
QVariant property (const char *name) const
 Returns the value of the object's name property.
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 Returns a pointer to the parent object.
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.
 

Protected Member Functions

virtual QVariant retrieveData (const QString &mimetype, QMetaType preferredType) const
 Returns a variant with the given type containing data for the MIME type specified by mimeType.
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr.
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal.
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 This event handler can be reimplemented in a subclass to receive timer events for the object.
 
virtual void childEvent (QChildEvent *event)
 This event handler can be reimplemented in a subclass to receive child events.
 
virtual void customEvent (QEvent *event)
 This event handler can be reimplemented in a subclass to receive custom events.
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 \threadsafe
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked.
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 This signal is emitted after the object's name has been changed.
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 \threadsafe
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 \threadsafe
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 Disconnect a connection.
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Properties inherited from QObject
QString objectName
 the name of this object
 

Detailed Description

\inmodule QtCore

The QMimeData class provides a container for data that records information about its MIME type.

QMimeData is used to describe information that can be stored in the \l{QClipboard}{clipboard}, and transferred via the \l{drag and drop} mechanism. QMimeData objects associate the data that they hold with the corresponding MIME types to ensure that information can be safely transferred between applications, and copied around within the same application.

QMimeData objects are usually created using new and supplied to QDrag or QClipboard objects. This is to enable Qt to manage the memory that they use.

A single QMimeData object can store the same data using several different formats at the same time. The formats() function returns a list of the available formats in order of preference. The data() function returns the raw data associated with a MIME type, and setData() allows you to set the data for a MIME type.

For the most common MIME types, QMimeData provides convenience functions to access the data:

\table \header

For example, if your write a widget that accepts URL drags, you would end up writing code like this:

void MyWidget::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasUrls())
event->acceptProposedAction();
}
void MyWidget::dropEvent(QDropEvent *event)
{
if (event->mimeData()->hasUrls()) {
foreach (QUrl url, event->mimeData()->urls()) {
...
}
}
}

There are three approaches for storing custom data in a QMimeData object:

\list 1

  • If the drag and drop operation occurs within a single application, we can subclass QMimeData and add extra data in it, and use a qobject_cast() in the receiver's drop event handler. For example:
void MyWidget::dropEvent(QDropEvent *event)
{
const MyMimeData *myData =
qobject_cast<const MyMimeData *>(event->mimeData());
if (myData) {
// access myData's data directly (not through QMimeData's API)
}
}

\endlist

Definition at line 15 of file qmimedata.h.

Constructor & Destructor Documentation

◆ QMimeData()

QMimeData::QMimeData ( )

Constructs a new MIME data object with no data in it.

Definition at line 309 of file qmimedata.cpp.

◆ ~QMimeData()

QMimeData::~QMimeData ( )

Destroys the MIME data object.

Definition at line 317 of file qmimedata.cpp.

Member Function Documentation

◆ clear()

void QMimeData::clear ( )

Removes all the MIME type and data entries in the object.

Definition at line 642 of file qmimedata.cpp.

References d.

Referenced by QHaikuClipboard::mimeData(), QQnxClipboard::mimeData(), QtWayland::DataDeviceManager::overrideSelection(), QtWayland::DataDeviceManager::setCurrentSelectionSource(), QCocoaClipboard::setMimeData(), and QQnxClipboard::setMimeData().

+ Here is the caller graph for this function:

◆ colorData()

QVariant QMimeData::colorData ( ) const

Returns a color if the data stored in the object represents a color (MIME type application/x-color); otherwise returns a null variant.

A QVariant is used because QMimeData belongs to the Qt Core module, whereas QColor belongs to Qt GUI. To convert the QVariant to a QColor, simply use qvariant_cast(). For example:

if (event->mimeData()->hasColor()) {
QColor color = qvariant_cast<QColor>(event->mimeData()->colorData());
...
}
See also
hasColor(), setColorData(), data()

Definition at line 511 of file qmimedata.cpp.

References applicationXColorLiteral(), and d.

Referenced by QWaylandMimeHelper::getByteArray(), and operator<<().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ data()

QByteArray QMimeData::data ( const QString & mimetype) const

Returns the data stored in the object in the format described by the MIME type specified by mimeType.

Definition at line 546 of file qmimedata.cpp.

References d, mimeType, and QVariant::toByteArray().

Referenced by QWaylandMimeHelper::getByteArray(), QWindowsOleDataObject::mimeData(), QtWayland::DataDeviceManager::overrideSelection(), dom::DataTransfer::setDataFromMimeData(), QHaikuClipboard::setMimeData(), ClipWindow::updateClipboard(), ClipWindow::updateData(), and QXcbDropData::xdndObtainData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ formats()

QStringList QMimeData::formats ( ) const
virtual

Returns a list of formats supported by the object.

This is a list of MIME types for which the object can return suitable data. The formats in the list are in a priority order.

For the most common types of data, you can call the higher-level functions hasText(), hasHtml(), hasUrls(), hasImage(), and hasColor() instead.

See also
hasFormat(), setData(), data()

Reimplemented in QInternalMimeData, QMacPasteboardMimeSource, QIOSMimeData, QQnxClipboard::MimeData, QTextEditMimeData, and QQuickTextEditMimeData.

Definition at line 607 of file qmimedata.cpp.

References d, list, and QList< T >::reserve().

Referenced by QtWaylandClient::QWaylandPrimarySelectionSourceV1::QWaylandPrimarySelectionSourceV1(), QWindowsOleDataObject::QWindowsOleDataObject(), QBuiltInMimes::canConvertFromMime(), QTextEditMimeData::formats(), QQuickTextEditMimeData::formats(), QBuiltInMimes::formatsForMime(), QQuickDropAreaPrivate::getKeys(), hasFormat(), QtWayland::DataDeviceManager::offerFromCompositorToClient(), QtWayland::DataDeviceManager::offerRetainedSelection(), operator<<(), QtWayland::DataDeviceManager::overrideSelection(), dom::DataTransfer::setDataFromMimeData(), QHaikuClipboard::setMimeData(), QWindowsClipboard::setMimeData(), and ClipWindow::updateClipboard().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasColor()

bool QMimeData::hasColor ( ) const

Returns true if the object can return a color (MIME type application/x-color); otherwise returns false.

See also
setColorData(), colorData(), hasFormat()

Definition at line 537 of file qmimedata.cpp.

References applicationXColorLiteral(), and hasFormat().

Referenced by operator<<().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasFormat()

bool QMimeData::hasFormat ( const QString & mimeType) const
virtual

Returns true if the object can return data for the MIME type specified by mimeType; otherwise returns false.

For the most common types of data, you can call the higher-level functions hasText(), hasHtml(), hasUrls(), hasImage(), and hasColor() instead.

See also
formats(), setData(), data()

Reimplemented in QInternalMimeData, and QQnxClipboard::MimeData.

Definition at line 591 of file qmimedata.cpp.

References formats(), and mimeType.

Referenced by hasColor(), hasHtml(), hasImage(), hasText(), hasUrls(), and QXcbMime::mimeDataForAtom().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasHtml()

bool QMimeData::hasHtml ( ) const

Returns true if the object can return HTML (MIME type text/html); otherwise returns false.

See also
setHtml(), html(), hasFormat()

Definition at line 447 of file qmimedata.cpp.

References hasFormat(), and textHtmlLiteral().

Referenced by operator<<(), and droparea::DropArea::paste().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasImage()

bool QMimeData::hasImage ( ) const

Returns true if the object can return an image; otherwise returns false.

See also
setImageData(), imageData(), hasFormat()

Definition at line 493 of file qmimedata.cpp.

References applicationXQtImageLiteral(), and hasFormat().

Referenced by QWindowsMimeImage::canConvertFromMime(), QWindowsMimeImage::convertFromMime(), QWindowsMimeImage::formatsForMime(), QWaylandMimeHelper::getByteArray(), QXcbDrag::handleDrop(), QXcbMime::mimeDataForAtom(), operator<<(), and droparea::DropArea::paste().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasText()

bool QMimeData::hasText ( ) const

Returns true if the object can return plain text (MIME type text/plain); otherwise returns false.

See also
setText(), text(), hasHtml(), hasFormat()

Definition at line 411 of file qmimedata.cpp.

References hasFormat(), hasUrls(), and textPlainLiteral().

Referenced by QWindowsMimeText::canConvertFromMime(), QQuickTextInput::canPaste(), QWindowsMimeText::formatsForMime(), operator<<(), and droparea::DropArea::paste().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasUrls()

bool QMimeData::hasUrls ( ) const

Returns true if the object can return a list of urls; otherwise returns false.

URLs correspond to the MIME type text/uri-list.

See also
setUrls(), urls(), hasFormat()

Definition at line 370 of file qmimedata.cpp.

References hasFormat(), and textUriListLiteral().

Referenced by QWindowsMimeURI::canConvertFromMime(), hasText(), and operator<<().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ html()

QString QMimeData::html ( ) const

Returns a string if the data stored in the object is HTML (MIME type text/html); otherwise returns an empty string.

See also
hasHtml(), setData()

Definition at line 422 of file qmimedata.cpp.

References d, textHtmlLiteral(), and QVariant::toString().

Referenced by QWindowsMimeHtml::canConvertFromMime(), QWindowsMimeHtml::convertFromMime(), QBuiltInMimes::convertFromMime(), QWindowsMimeHtml::formatsForMime(), operator<<(), droparea::DropArea::paste(), and setHtml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imageData()

QVariant QMimeData::imageData ( ) const

Returns a QVariant storing a QImage if the object can return an image; otherwise returns a null variant.

A QVariant is used because QMimeData belongs to the Qt Core module, whereas QImage belongs to Qt GUI. To convert the QVariant to a QImage, simply use qvariant_cast(). For example:

if (event->mimeData()->hasImage()) {
QImage image = qvariant_cast<QImage>(event->mimeData()->imageData());
...
}
See also
hasImage()

Definition at line 464 of file qmimedata.cpp.

References applicationXQtImageLiteral(), and d.

Referenced by QWindowsMimeImage::canConvertFromMime(), QWindowsMimeImage::convertFromMime(), QWindowsMimeImage::formatsForMime(), QWaylandMimeHelper::getByteArray(), operator<<(), and droparea::DropArea::paste().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeFormat()

void QMimeData::removeFormat ( const QString & mimeType)
Since
4.4

Removes the data entry for mimeType in the object.

Definition at line 653 of file qmimedata.cpp.

References d, and mimeType.

◆ retrieveData()

QVariant QMimeData::retrieveData ( const QString & mimeType,
QMetaType type ) const
protectedvirtual

Returns a variant with the given type containing data for the MIME type specified by mimeType.

If the object does not support the MIME type or variant type given, a null variant is returned instead.

This function is called by the general data() getter and by the convenience getters (text(), html(), urls(), imageData(), and colorData()). You can reimplement it if you want to store your data using a custom data structure (instead of a QByteArray, which is what setData() provides). You would then also need to reimplement hasFormat() and formats().

See also
data()

Reimplemented in QMacPasteboardMimeSource, QQnxClipboard::MimeData, QInternalMimeData, QIOSMimeData, QTextEditMimeData, and QQuickTextEditMimeData.

Definition at line 632 of file qmimedata.cpp.

References d, mimeType, and Q_UNUSED.

Referenced by QQnxClipboard::MimeData::retrieveData(), QInternalMimeData::retrieveData(), QTextEditMimeData::retrieveData(), QQuickTextEditMimeData::retrieveData(), and QMacMimeData::variantData().

+ Here is the caller graph for this function:

◆ setColorData()

void QMimeData::setColorData ( const QVariant & color)

Sets the color data in the object to the given color.

Colors correspond to the MIME type application/x-color.

See also
hasColor(), setData()

Definition at line 524 of file qmimedata.cpp.

References applicationXColorLiteral(), and d.

+ Here is the call graph for this function:

◆ setData()

void QMimeData::setData ( const QString & mimeType,
const QByteArray & data )

Sets the data associated with the MIME type given by mimeType to the specified data.

For the most common types of data, you can call the higher-level functions setText(), setHtml(), setUrls(), setImageData(), and setColorData() instead.

Note that if you want to use a custom data type in an item view drag and drop operation, you must register it as a Qt \l{QMetaType}{meta type}, using the Q_DECLARE_METATYPE() macro, and implement stream operators for it.

See also
hasFormat(), QMetaType, {QMetaType::}{Q_DECLARE_METATYPE()}

Definition at line 567 of file qmimedata.cpp.

References ba, QByteArray::chop(), d, dataToUrls(), QByteArray::endsWith(), and mimeType.

Referenced by QQuickDragAttachedPrivate::createMimeData(), QCocoaDrag::drag(), DragDropListModel::mimeData(), QHaikuClipboard::mimeData(), DragWidget::mouseMoveEvent(), FinalWidget::mouseMoveEvent(), QtWayland::DataDeviceManager::overrideSelection(), and QInternalMimeData::retrieveData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHtml()

void QMimeData::setHtml ( const QString & html)

Sets html as the HTML (MIME type text/html) used to represent the data.

See also
hasHtml(), setText(), setData()

Definition at line 435 of file qmimedata.cpp.

References d, html(), and textHtmlLiteral().

Referenced by QQuickDragAttachedPrivate::createMimeData(), and QHaikuClipboard::mimeData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setImageData()

void QMimeData::setImageData ( const QVariant & image)

Sets the data in the object to the given image.

A QVariant is used because QMimeData belongs to the Qt Core module, whereas QImage belongs to Qt GUI. The conversion from QImage to QVariant is implicit. For example:

See also
hasImage(), setData()

Definition at line 481 of file qmimedata.cpp.

References applicationXQtImageLiteral(), and d.

Referenced by QQuickDragAttachedPrivate::createMimeData(), QClipboard::setImage(), QClipboard::setPixmap(), and src_gui_kernel_qclipboard::wrapper().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setText()

void QMimeData::setText ( const QString & text)

Sets text as the plain text (MIME type text/plain) used to represent the data.

See also
hasText(), setHtml(), setData()

Definition at line 399 of file qmimedata.cpp.

References d, text(), and textPlainLiteral().

Referenced by QWidgetTextControlPrivate::_q_copyLink(), QQuickDragAttachedPrivate::createMimeData(), QHaikuClipboard::mimeData(), MainWindow::mousePressEvent(), and QClipboard::setText().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUrls()

void QMimeData::setUrls ( const QList< QUrl > & urls)

Sets the URLs stored in the MIME data object to those specified by urls.

URLs correspond to the MIME type text/uri-list.

Since Qt 5.0, setUrls also exports the urls as plain text, if setText was not called before, to make it possible to drop them into any lineedit and text editor.

See also
hasUrls(), setData()

Definition at line 356 of file qmimedata.cpp.

References QList< T >::cbegin(), QList< T >::cend(), d, textUriListLiteral(), and urls().

Referenced by QQuickDragAttachedPrivate::createMimeData(), and dom::DataTransfer::toMimeDataWithFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ text()

QString QMimeData::text ( ) const

Returns a plain text (MIME type text/plain) representation of the data.

See also
hasText(), html(), data()

Definition at line 382 of file qmimedata.cpp.

References d, QVariant::isNull(), textPlainLiteral(), textPlainUtf8Literal(), and QVariant::toString().

Referenced by QQuickTextInput::canPaste(), QWindowsMimeText::convertFromMime(), QWaylandMimeHelper::getByteArray(), operator<<(), droparea::DropArea::paste(), and setText().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ urls()

QList< QUrl > QMimeData::urls ( ) const

Returns a list of URLs contained within the MIME data object.

URLs correspond to the MIME type text/uri-list.

See also
hasUrls(), data()

Definition at line 328 of file qmimedata.cpp.

References QList< T >::append(), d, list, textUriListLiteral(), QList< T >::toList(), and urls().

Referenced by QWindowsMimeURI::canConvertFromMime(), QWindowsMimeURI::convertFromMime(), QMacMimeFileUri::count(), QWaylandMimeHelper::getByteArray(), QXcbMime::mimeConvertToFormat(), operator<<(), setUrls(), and urls().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: