slint::DataTransfer Struct
struct DataTransfer;#include <slint.h>DataTransfer abstracts over the various ways of transferring data within an application and between applications. The details will depend on the current platform, but the common features are:
- Each
DataTransfercontains multiple views over the same data in different formats, specified by MIME type - The
DataTransfermay contain an in-memory representation of the data, which can be sent and received within the current application - Serializing to a given format may be done eagerly or lazily
Public Functions
Section titled “Public Functions” DataTransfer
Section titled “ DataTransfer”slint::DataTransfer::DataTransfer()
Default constructor for DataTransfer
DataTransfer
Section titled “ DataTransfer”explicit slint::DataTransfer::DataTransfer(const SharedString &string)
Constructs a DataTransfer whose plaintext representation is string.
DataTransfer
Section titled “ DataTransfer”explicit slint::DataTransfer::DataTransfer(const Image &image)
Constructs a DataTransfer whose image representation is image. Conversion to the relevant format is done on-demand.
~DataTransfer
Section titled “ ~DataTransfer”slint::DataTransfer::~DataTransfer()
Destroys this DataTransfer, releasing any data it holds.
DataTransfer
Section titled “ DataTransfer”slint::DataTransfer::DataTransfer(const DataTransfer &other)
Creates a new DataTransfer that shares the data of other.
operator=
Section titled “ operator=”DataTransfer & slint::DataTransfer::operator=(const DataTransfer &other)
Assigns other to this DataTransfer and returns a reference to this.
DataTransfer
Section titled “ DataTransfer”slint::DataTransfer::DataTransfer(DataTransfer &&other) noexcept
Move-constructs a DataTransfer from other, leaving other in a default-constructed state.
operator=
Section titled “ operator=”DataTransfer & slint::DataTransfer::operator=(DataTransfer &&other) noexcept
Move-assigns other to this DataTransfer and returns a reference to this.
set_plaintext
Section titled “ set_plaintext”void slint::DataTransfer::set_plaintext(const SharedString &text)
Sets the plaintext representation of this DataTransfer. Each DataTransfer can only have a single plaintext representation; calling this again overwrites the previous one.
set_image
Section titled “ set_image”void slint::DataTransfer::set_image(const Image &image)
Sets the image representation of this DataTransfer. Each DataTransfer can only have a single image representation; calling this again overwrites the previous one.
has_plaintext
Section titled “ has_plaintext”bool slint::DataTransfer::has_plaintext() const
Returns true if this data transfer advertises a plaintext representation.
has_image
Section titled “ has_image”bool slint::DataTransfer::has_image() const
Returns true if this data transfer advertises an image representation.
is_empty
Section titled “ is_empty”bool slint::DataTransfer::is_empty() const
Returns true if this DataTransfer carries no data: no plaintext, no image, and no user data.
fetch_plaintext
Section titled “ fetch_plaintext”std::optional< SharedString > slint::DataTransfer::fetch_plaintext() const
Returns the plaintext representation of this DataTransfer, or std::nullopt if no plaintext representation is available.
fetch_image
Section titled “ fetch_image”std::optional< Image > slint::DataTransfer::fetch_image() const
Returns the image representation of this DataTransfer, or std::nullopt if no image representation is available.
set_user_data
Section titled “ set_user_data”void slint::DataTransfer::set_user_data(std::any value)
Overload of set_user_data() for callers that already hold a std::any.
user_data
Section titled “ user_data”std::any slint::DataTransfer::user_data() const
Returns the user data, or an empty std::any if none is set. Use std::any_cast to extract the concrete value.
has_user_data
Section titled “ has_user_data”bool slint::DataTransfer::has_user_data() const
Returns true if this DataTransfer holds user data.
clear_user_data
Section titled “ clear_user_data”void slint::DataTransfer::clear_user_data()
Clears the user data, if any.
Friends
Section titled “Friends” operator==
Section titled “ operator==”bool operator==(const DataTransfer &a, const DataTransfer &b)
Compare two DataTransfer values for equality. This will return true if b is an unmodified clone of a, but if any modification has been done to either value since cloning then this will return false even if the two values are semantically identical.
© 2026 SixtyFPS GmbH