QFormDataBuilder Class
The QFormDataBuilder class is a convenience class to simplify the construction of QHttpMultiPart objects. More...
Header: | #include <QFormDataBuilder> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Network) target_link_libraries(mytarget PRIVATE Qt6::Network) |
qmake: | QT += network |
Since: | Qt 6.8 |
- List of all members, including inherited members
- QFormDataBuilder is part of Network Programming API and Implicitly Shared Classes.
Public Functions
QFormDataBuilder() | |
QFormDataBuilder(QFormDataBuilder &&other) | |
~QFormDataBuilder() | |
std::unique_ptr<QHttpMultiPart> | buildMultiPart() |
QFormDataPartBuilder & | part(QAnyStringView name) |
QFormDataBuilder & | operator=(QFormDataBuilder &&other) |
Detailed Description
The QFormDataBuilder class can be used to build a QHttpMultiPart object with the content type set to be FormDataType by default.
The snippet below demonstrates how to build a multipart message with QFormDataBuilder:
QFormDataBuilder builder; QFile image(u"../../pic.png"_s); image.open(QFile::ReadOnly); QFile mask(u"../../mask.png"_s); mask.open(QFile::ReadOnly); builder.part("image"_L1).setBodyDevice(&image, "the actual image"); builder.part("mask"_L1).setBodyDevice(&mask, "the mask image"); builder.part("prompt"_L1).setBody("Lobster wearing a beret"); builder.part("n"_L1).setBody("2"); builder.part("size"_L1).setBody("512x512"); std::unique_ptr<QHttpMultiPart> mp = builder.buildMultiPart();
See also QHttpPart, QHttpMultiPart, and QFormDataPartBuilder.
Member Function Documentation
QFormDataBuilder::QFormDataBuilder()
Constructs an empty QFormDataBuilder object.
[noexcept]
QFormDataBuilder::QFormDataBuilder(QFormDataBuilder &&other)
Move-constructs a QFormDataBuilder instance, making it point at the same object that other was pointing to.
[noexcept]
QFormDataBuilder::~QFormDataBuilder()
Destroys the QFormDataBuilder object.
std::unique_ptr<QHttpMultiPart> QFormDataBuilder::buildMultiPart()
Constructs and returns a pointer to a QHttpMultipart object.
See also QHttpMultiPart.
QFormDataPartBuilder &QFormDataBuilder::part(QAnyStringView name)
Constructs and returns a reference to a QFormDataPartBuilder object and sets name as the name parameter of the form-data. The returned reference is valid until the next call to this function.
Limiting name characters to US-ASCII is strongly recommended for interoperability reasons.
See also QFormDataPartBuilder and QHttpPart.
[noexcept]
QFormDataBuilder &QFormDataBuilder::operator=(QFormDataBuilder &&other)
Move-assigns other to this QFormDataBuilder instance.