10#include <QPrintDialog>
43 tr(
"Open file"), currentFile,
"HTML files (*.html);;Text files (*.txt)");
79 document->print(&printer);
void close() override
Calls QFileDevice::flush() and closes the file.
static QString getOpenFileName(QWidget *parent=nullptr, const QString &caption=QString(), const QString &dir=QString(), const QString &filter=QString(), QString *selectedFilter=nullptr, Options options=Options())
This is a convenience static function that returns an existing file selected by the user.
\inmodule QtCore \reentrant
QString completeSuffix() const
Returns the complete suffix (extension) of the file.
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
The QKeySequence class encapsulates a key sequence as used by shortcuts.
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
The QPrintDialog class provides a dialog for specifying the printer's configuration.
int exec() override
\reimp
void setOutputFormat(OutputFormat format)
\macro QT_RESTRICTED_CAST_FROM_ASCII
\reentrant \inmodule QtGui
void print(QPagedPaintDevice *printer) const
Prints the document to the given printer.
The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
void setPlainText(const QString &text)
Changes the text of the text edit to the string text.
void setHtml(const QString &text)
void setDocument(QTextDocument *document)
QTextDocument * document
the underlying document of the text editor.
void selectionChanged()
This signal is emitted whenever the selection changes.
QFileInfo info(fileName)
[8]
QPrintDialog printDialog(printer, parent)
[0]