5#include <QtPrintSupport/qtprintsupportglobal.h>
6#if QT_CONFIG(printdialog)
34 #if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
37 printer.setOutputFileName(
"test.pdf");
42 const auto pageLayout = printer.pageLayout();
43 const auto pageRect = pageLayout.paintRectPixels(printer.resolution());
44 const auto paperRect = pageLayout.fullRectPixels(printer.resolution());
45 double xscale = pageRect.width() / double(myWidget->
width());
46 double yscale = pageRect.height() / double(myWidget->
height());
49 pageRect.y() + paperRect.height() / 2.);
60 #if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
71 editor->
print(&printer);
The QApplication class manages the GUI application's control flow and main settings.
static int exec()
Enters the main event loop and waits until exit() is called, then returns the value that was set to e...
virtual int exec()
Shows the dialog as a \l{QDialog::Modal Dialogs}{modal dialog}, blocking until the user closes it.
void addWidget(QWidget *w)
Adds widget w to this layout in a manner specific to the layout.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
The QPainter class performs low-level painting on widgets and other paint devices.
bool begin(QPaintDevice *)
Begins painting the paint device and returns true if successful; otherwise returns false.
void scale(qreal sx, qreal sy)
Scales the coordinate system by ({sx}, {sy}).
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
The QPrintDialog class provides a dialog for specifying the printer's configuration.
bool hasSelection() const
Returns true if the cursor contains a selection; otherwise returns false.
The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
QTextCursor textCursor() const
Returns a copy of the QTextCursor that represents the currently visible cursor.
void print(QPagedPaintDevice *printer) const
The QVBoxLayout class lines up widgets vertically.
[Window class with invokable method]
constexpr const T & qMin(const T &a, const T &b)
GLenum GLenum GLuint GLint GLint GLint yscale
GLenum GLenum GLuint GLint GLint xscale
GLenum GLenum GLenum GLenum GLenum scale
QFileDialog dialog(this)
[1]
QApplication app(argc, argv)
[0]