Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qprintpreviewdialog.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
6#include <private/qprinter_p.h>
7#include "qprintdialog.h"
8
9#include <QtGui/qaction.h>
10#include <QtGui/qactiongroup.h>
11#include <QtWidgets/qboxlayout.h>
12#include <QtWidgets/qcombobox.h>
13#include <QtWidgets/qlineedit.h>
14#include <QtPrintSupport/qpagesetupdialog.h>
15#include <QtPrintSupport/qprinter.h>
16#include <QtWidgets/qstyle.h>
17#include <QtWidgets/qtoolbutton.h>
18#include <QtGui/qvalidator.h>
19#if QT_CONFIG(filedialog)
20#include <QtWidgets/qfiledialog.h>
21#endif
22#include <QtWidgets/qmainwindow.h>
23#include <QtWidgets/qtoolbar.h>
24#include <QtCore/QCoreApplication>
25
26#include "private/qdialog_p.h"
27
28#include <QtWidgets/qformlayout.h>
29#include <QtWidgets/qlabel.h>
30
32{
33 static bool resourcesInitialized = false;
34 if (!resourcesInitialized) {
35 Q_INIT_RESOURCE(qprintdialog);
36 resourcesInitialized = true;
37 }
38}
39
41
42using namespace Qt::StringLiterals;
43
44namespace {
45class QPrintPreviewMainWindow : public QMainWindow
46{
47public:
48 QPrintPreviewMainWindow(QWidget *parent) : QMainWindow(parent) {}
49 QMenu *createPopupMenu() override { return nullptr; }
50};
51
52class ZoomFactorValidator : public QDoubleValidator
53{
54public:
55 ZoomFactorValidator(QObject* parent)
57 ZoomFactorValidator(qreal bottom, qreal top, int decimals, QObject *parent)
58 : QDoubleValidator(bottom, top, decimals, parent) {}
59
60 State validate(QString &input, int &pos) const override
61 {
62 bool replacePercent = false;
63 if (input.endsWith(u'%')) {
64 input = input.left(input.size() - 1);
65 replacePercent = true;
66 }
68 if (replacePercent)
69 input += u'%';
70 const int num_size = 4;
71 if (state == Intermediate) {
72 int i = input.indexOf(QLocale::system().decimalPoint());
73 if ((i == -1 && input.size() > num_size)
74 || (i != -1 && i > num_size))
75 return Invalid;
76 }
77 return state;
78 }
79};
80
81class LineEdit : public QLineEdit
82{
84public:
85 LineEdit(QWidget* parent = nullptr)
87 {
89 connect(this, &LineEdit::returnPressed, this, &LineEdit::handleReturnPressed);
90 }
91
92protected:
93 void focusInEvent(QFocusEvent *e) override
94 {
95 origText = text();
97 }
98
99 void focusOutEvent(QFocusEvent *e) override
100 {
101 if (isModified() && !hasAcceptableInput())
102 setText(origText);
104 }
105
106private slots:
107 void handleReturnPressed()
108 {
109 origText = text();
110 }
111
112private:
113 QString origText;
114};
115} // anonymous namespace
116
118{
119 Q_DECLARE_PUBLIC(QPrintPreviewDialog)
120public:
124
125 // private slots
126 void _q_fit(QAction *action);
127 void _q_zoomIn();
128 void _q_zoomOut();
129 void _q_navigate(QAction *action);
130 void _q_setMode(QAction *action);
131 void _q_pageNumEdited();
132 void _q_print();
133 void _q_pageSetup();
134 void _q_previewChanged();
136
137 void init(QPrinter *printer = nullptr);
140 void setupActions();
141 void updateNavActions();
142 void setFitting(bool on);
143 bool isFitting();
144 void updatePageNumLabel();
145 void updateZoomFactor();
146
153
154 // widgets:
158
159 // actions:
165
169
173
177
182
186
189};
190
192{
194
196
197 if (_printer) {
198 preview = new QPrintPreviewWidget(_printer, q);
199 printer = _printer;
200 } else {
201 ownPrinter = true;
202 printer = new QPrinter;
204 }
205 QObject::connect(preview, SIGNAL(paintRequested(QPrinter*)), q, SIGNAL(paintRequested(QPrinter*)));
206 QObject::connect(preview, SIGNAL(previewChanged()), q, SLOT(_q_previewChanged()));
207 setupActions();
208
209 pageNumEdit = new LineEdit;
212 pageNumLabel = new QLabel;
213 QObject::connect(pageNumEdit, SIGNAL(editingFinished()), q, SLOT(_q_pageNumEdited()));
214
215 zoomFactor = new QComboBox;
216 zoomFactor->setEditable(true);
219 LineEdit *zoomEditor = new LineEdit;
220 zoomEditor->setValidator(new ZoomFactorValidator(1, 1000, 1, zoomEditor));
221 zoomFactor->setLineEdit(zoomEditor);
222 static const short factorsX2[] = { 25, 50, 100, 200, 250, 300, 400, 800, 1600 };
223 for (auto factorX2 : factorsX2)
224 zoomFactor->addItem(QPrintPreviewDialog::tr("%1%").arg(factorX2 / 2.0));
225 QObject::connect(zoomFactor->lineEdit(), SIGNAL(editingFinished()),
227 QObject::connect(zoomFactor, SIGNAL(currentIndexChanged(int)),
229
230 QPrintPreviewMainWindow *mw = new QPrintPreviewMainWindow(q);
231 QToolBar *toolbar = new QToolBar(mw);
232 toolbar->addAction(fitWidthAction);
233 toolbar->addAction(fitPageAction);
234 toolbar->addSeparator();
235 toolbar->addWidget(zoomFactor);
236 toolbar->addAction(zoomOutAction);
237 toolbar->addAction(zoomInAction);
238 toolbar->addSeparator();
239 toolbar->addAction(portraitAction);
240 toolbar->addAction(landscapeAction);
241 toolbar->addSeparator();
242 toolbar->addAction(firstPageAction);
243 toolbar->addAction(prevPageAction);
244
245 // this is to ensure the label text and the editor text are
246 // aligned in all styles - the extra QVBoxLayout is a workaround
247 // for bug in QFormLayout
248 QWidget *pageEdit = new QWidget(toolbar);
249 QVBoxLayout *vboxLayout = new QVBoxLayout;
250 vboxLayout->setContentsMargins(0, 0, 0, 0);
251#ifdef Q_OS_MAC
252 // We query the widgets about their size and then we fix the size.
253 // This should do the trick for the laying out part...
254 QSize pageNumEditSize, pageNumLabelSize;
255 pageNumEditSize = pageNumEdit->minimumSizeHint();
256 pageNumLabelSize = pageNumLabel->minimumSizeHint();
257 pageNumEdit->resize(pageNumEditSize);
258 pageNumLabel->resize(pageNumLabelSize);
259#endif
261#ifdef Q_OS_MAC
262 // We have to change the growth policy in Mac.
264#endif
267 vboxLayout->addLayout(formLayout);
268 vboxLayout->setAlignment(Qt::AlignVCenter);
269 pageEdit->setLayout(vboxLayout);
270 toolbar->addWidget(pageEdit);
271
272 toolbar->addAction(nextPageAction);
273 toolbar->addAction(lastPageAction);
274 toolbar->addSeparator();
275 toolbar->addAction(singleModeAction);
276 toolbar->addAction(facingModeAction);
278 toolbar->addSeparator();
279 toolbar->addAction(pageSetupAction);
280 toolbar->addAction(printAction);
281
282 // Cannot use the actions' triggered signal here, since it doesn't autorepeat
283 QToolButton *zoomInButton = static_cast<QToolButton *>(toolbar->widgetForAction(zoomInAction));
284 QToolButton *zoomOutButton = static_cast<QToolButton *>(toolbar->widgetForAction(zoomOutAction));
285 zoomInButton->setAutoRepeat(true);
286 zoomInButton->setAutoRepeatInterval(200);
287 zoomInButton->setAutoRepeatDelay(200);
288 zoomOutButton->setAutoRepeat(true);
289 zoomOutButton->setAutoRepeatInterval(200);
290 zoomOutButton->setAutoRepeatDelay(200);
291 QObject::connect(zoomInButton, SIGNAL(clicked()), q, SLOT(_q_zoomIn()));
292 QObject::connect(zoomOutButton, SIGNAL(clicked()), q, SLOT(_q_zoomOut()));
293
294 mw->addToolBar(toolbar);
295 mw->setCentralWidget(preview);
296 // QMainWindows are always created as top levels, force it to be a
297 // plain widget
298 mw->setParent(q, Qt::Widget);
299
300 QVBoxLayout *topLayout = new QVBoxLayout;
301 topLayout->addWidget(mw);
302 topLayout->setContentsMargins(0, 0, 0, 0);
303 q->setLayout(topLayout);
304
305 QString caption = QCoreApplication::translate("QPrintPreviewDialog", "Print Preview");
306 if (!printer->docName().isEmpty())
307 caption += ": "_L1 + printer->docName();
308 q->setWindowTitle(caption);
309
310 if (!printer->isValid()
311#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
313#endif
314 )
316 preview->setFocus();
317}
318
320{
321 const auto imagePrefix = ":/qt-project.org/dialogs/qprintpreviewdialog/images/"_L1;
323 icon.addFile(imagePrefix + name + "-24.png"_L1, QSize(24, 24));
324 icon.addFile(imagePrefix + name + "-32.png"_L1, QSize(32, 32));
325 action->setIcon(icon);
326}
327
329{
331
332 // Navigation
333 navGroup = new QActionGroup(q);
334 navGroup->setExclusive(false);
335 nextPageAction = navGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Next page"));
336 prevPageAction = navGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Previous page"));
337 firstPageAction = navGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "First page"));
338 lastPageAction = navGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Last page"));
339 qt_setupActionIcon(nextPageAction, "go-next"_L1);
340 qt_setupActionIcon(prevPageAction, "go-previous"_L1);
341 qt_setupActionIcon(firstPageAction, "go-first"_L1);
342 qt_setupActionIcon(lastPageAction, "go-last"_L1);
344
345
346 fitGroup = new QActionGroup(q);
347 fitWidthAction = fitGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Fit width"));
348 fitPageAction = fitGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Fit page"));
349 fitWidthAction->setObjectName("fitWidthAction"_L1);
350 fitPageAction->setObjectName("fitPageAction"_L1);
353 qt_setupActionIcon(fitWidthAction, "zoom-fit-width"_L1);
354 qt_setupActionIcon(fitPageAction, "zoom-fit-page"_L1);
356
357 // Zoom
358 zoomGroup = new QActionGroup(q);
359 zoomInAction = zoomGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Zoom in"));
360 zoomOutAction = zoomGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Zoom out"));
361 qt_setupActionIcon(zoomInAction, "zoom-in"_L1);
362 qt_setupActionIcon(zoomOutAction, "zoom-out"_L1);
363
364 // Portrait/Landscape
366 portraitAction = orientationGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Portrait"));
367 landscapeAction = orientationGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Landscape"));
370 qt_setupActionIcon(portraitAction, "layout-portrait"_L1);
371 qt_setupActionIcon(landscapeAction, "layout-landscape"_L1);
372 QObject::connect(portraitAction, SIGNAL(triggered(bool)), preview, SLOT(setPortraitOrientation()));
373 QObject::connect(landscapeAction, SIGNAL(triggered(bool)), preview, SLOT(setLandscapeOrientation()));
374
375 // Display mode
376 modeGroup = new QActionGroup(q);
377 singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
378 facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
379 overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
380 qt_setupActionIcon(singleModeAction, "view-pages-single"_L1);
381 qt_setupActionIcon(facingModeAction, "view-pages-facing"_L1);
382 qt_setupActionIcon(overviewModeAction, "view-pages-overview"_L1);
383 singleModeAction->setObjectName("singleModeAction"_L1);
384 facingModeAction->setObjectName("facingModeAction"_L1);
385 overviewModeAction->setObjectName("overviewModeAction"_L1);
386
391
392 // Print
394 printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
395 pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
396 qt_setupActionIcon(printAction, "printer"_L1);
397 qt_setupActionIcon(pageSetupAction, "page-setup"_L1);
398 QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
400
401 // Initial state:
406 else
408}
409
410
412{
413 return (fitGroup->isExclusive()
415}
416
417
419{
420 if (isFitting() == on)
421 return;
423 if (on) {
425 action->setChecked(true);
426 if (fitGroup->checkedAction() != action) {
427 // work around exclusitivity problem
428 fitGroup->removeAction(action);
429 fitGroup->addAction(action);
430 }
431 } else {
434 }
435}
436
438{
439 int curPage = preview->currentPage();
440 int numPages = preview->pageCount();
441 nextPageAction->setEnabled(curPage < numPages);
442 prevPageAction->setEnabled(curPage > 1);
443 firstPageAction->setEnabled(curPage > 1);
444 lastPageAction->setEnabled(curPage < numPages);
446}
447
449{
451
452 int numPages = preview->pageCount();
453 int maxChars = QString::number(numPages).size();
454 pageNumLabel->setText(QString::fromLatin1("/ %1").arg(numPages));
455 int cyphersWidth = q->fontMetrics().horizontalAdvance(QString().fill(u'8', maxChars));
456 int maxWidth = pageNumEdit->minimumSizeHint().width() + cyphersWidth;
457 pageNumEdit->setMinimumWidth(maxWidth);
458 pageNumEdit->setMaximumWidth(maxWidth);
460 // any old one will be deleted later along with its parent pageNumEdit
461}
462
464{
466}
467
469{
470 setFitting(true);
471 if (action == fitPageAction)
473 else
475}
476
478{
479 setFitting(false);
480 preview->zoomIn();
482}
483
485{
486 setFitting(false);
487 preview->zoomOut();
489}
490
492{
493 bool ok = false;
494 int res = pageNumEdit->text().toInt(&ok);
495 if (ok)
497}
498
500{
501 int curPage = preview->currentPage();
502 if (action == prevPageAction)
503 preview->setCurrentPage(curPage - 1);
504 else if (action == nextPageAction)
505 preview->setCurrentPage(curPage + 1);
506 else if (action == firstPageAction)
508 else if (action == lastPageAction)
511}
512
514{
515 if (action == overviewModeAction) {
517 setFitting(false);
518 fitGroup->setEnabled(false);
519 navGroup->setEnabled(false);
520 pageNumEdit->setEnabled(false);
521 pageNumLabel->setEnabled(false);
522 } else if (action == facingModeAction) {
524 } else {
526 }
527 if (action == facingModeAction || action == singleModeAction) {
528 fitGroup->setEnabled(true);
529 navGroup->setEnabled(true);
530 pageNumEdit->setEnabled(true);
532 setFitting(true);
533 }
534}
535
537{
539
540#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
542 QString title = QCoreApplication::translate("QPrintPreviewDialog", "Export to PDF");
543 QString suffix = ".pdf"_L1;
545#if QT_CONFIG(filedialog)
547#endif
548 if (!fileName.isEmpty()) {
549 if (QFileInfo(fileName).suffix().isEmpty())
550 fileName.append(suffix);
552 }
554 preview->print();
555 q->accept();
556 return;
557 }
558#endif
559
560 if (!printDialog)
563 preview->print();
564 q->accept();
565 }
566}
567
569{
571
572 if (!pageSetupDialog)
574
576 // update possible orientation changes
580 }else {
583 }
584 }
585}
586
588{
592}
593
595{
597 bool ok;
598 qreal factor = text.remove(u'%').toFloat(&ok);
599 factor = qMax(qreal(1.0), qMin(qreal(1000.0), factor));
600 if (ok) {
601 preview->setZoomFactor(factor/100.0);
603 setFitting(false);
604 }
605}
606
608
657{
659 d->init(printer);
660}
661
671{
673 d->init();
674}
675
680{
682 if (d->ownPrinter)
683 delete d->printer;
684 delete d->printDialog;
685 delete d->pageSetupDialog;
686}
687
692{
694 // this will make the dialog get a decent default size
695 if (visible && !d->initialized) {
696 d->preview->updatePreview();
697 d->initialized = true;
698 }
700}
701
706{
709 if (d->receiverToDisconnectOnClose) {
710 disconnect(this, SIGNAL(finished(int)),
711 d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
712 d->receiverToDisconnectOnClose = nullptr;
713 }
714 d->memberToDisconnectOnClose.clear();
715}
716
726void QPrintPreviewDialog::open(QObject *receiver, const char *member)
727{
729 // the int parameter isn't very useful here; we could just as well connect
730 // to reject(), but this feels less robust somehow
731 connect(this, SIGNAL(finished(int)), receiver, member);
732 d->receiverToDisconnectOnClose = receiver;
733 d->memberToDisconnectOnClose = member;
735}
736
742{
744 return d->printer;
745}
746
760
761#include "moc_qprintpreviewdialog.cpp"
762#include "qprintpreviewdialog.moc"
void setAutoRepeatDelay(int)
void setAutoRepeatInterval(int)
The QActionGroup class groups actions together.
void setEnabled(bool)
QAction * checkedAction() const
Returns the currently checked action in the group, or \nullptr if none are checked.
void removeAction(QAction *a)
Removes the action from this group.
bool isExclusive() const
Returns true if the group is exclusive.
void setExclusive(bool)
Enable or disable the group exclusion checking.
QAction * addAction(QAction *a)
Adds the action to this group, and returns it.
The QAction class provides an abstraction for user commands that can be added to different user inter...
Definition qaction.h:30
void setChecked(bool)
Definition qaction.cpp:877
void setIcon(const QIcon &icon)
Definition qaction.cpp:547
void setEnabled(bool)
Definition qaction.cpp:927
void setCheckable(bool)
Definition qaction.cpp:832
bool isChecked() const
Definition qaction.cpp:892
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment.
void addLayout(QLayout *layout, int stretch=0)
Adds layout to the end of the box, with serial stretch factor stretch.
\inmodule QtCore
Definition qbytearray.h:57
The QComboBox widget is a combined button and popup list.
Definition qcombobox.h:24
void setInsertPolicy(InsertPolicy policy)
QLineEdit * lineEdit() const
Returns the line edit used to edit items in the combobox, or \nullptr if there is no line edit.
void setMinimumContentsLength(int characters)
void addItem(const QString &text, const QVariant &userData=QVariant())
Adds an item to the combobox with the given text, and containing the specified userData (stored in th...
Definition qcombobox.h:224
void setEditText(const QString &text)
Sets the text in the combobox's text edit.
void setLineEdit(QLineEdit *edit)
Sets the line edit to use instead of the current line edit widget.
void setEditable(bool editable)
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
The QDialog class is the base class of dialog windows.
Definition qdialog.h:19
void finished(int result)
@ Accepted
Definition qdialog.h:30
virtual void done(int)
Closes the dialog and sets its result code to r.
Definition qdialog.cpp:598
virtual void open()
Definition qdialog.cpp:499
The QDoubleValidator class provides range checking of floating-point numbers.
Definition qvalidator.h:89
QValidator::State validate(QString &, int &) const override
Returns \l Acceptable if the string input is in the correct format and contains a double within the v...
static QString getSaveFileName(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 will return a file name selected by the user.
\inmodule QtCore \reentrant
Definition qfileinfo.h:22
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:469
The QFormLayout class manages forms of input widgets and their associated labels.
Definition qformlayout.h:18
void setWidget(int row, ItemRole role, QWidget *widget)
Sets the widget in the given row for the given role to widget, extending the layout with empty rows i...
void setFieldGrowthPolicy(FieldGrowthPolicy policy)
@ AllNonFixedFieldsGrow
Definition qformlayout.h:36
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
void addFile(const QString &fileName, const QSize &size=QSize(), Mode mode=Normal, State state=Off)
Adds an image from the file with the given fileName to the icon, as a specialization for size,...
Definition qicon.cpp:1067
static QIcon fromTheme(const QString &name)
Definition qicon.cpp:1296
The QIntValidator class provides a validator that ensures a string contains a valid integer within a ...
Definition qvalidator.h:56
The QLabel widget provides a text or image display.
Definition qlabel.h:20
void setText(const QString &)
Definition qlabel.cpp:263
QSize minimumSizeHint() const override
\reimp
Definition qlabel.cpp:831
bool setAlignment(QWidget *w, Qt::Alignment alignment)
Sets the alignment for widget w to alignment and returns true if w is found in this layout (not inclu...
Definition qlayout.cpp:199
void setContentsMargins(int left, int top, int right, int bottom)
Definition qlayout.cpp:288
The QLineEdit widget is a one-line text editor.
Definition qlineedit.h:28
QSize minimumSizeHint() const override
Returns a minimum size for the line edit.
void setValidator(const QValidator *)
Sets the validator for values of line edit to v.
void setAlignment(Qt::Alignment flag)
bool hasAcceptableInput() const
void focusOutEvent(QFocusEvent *) override
\reimp
void setText(const QString &)
QString text
the line edit's text.
Definition qlineedit.h:32
bool isModified() const
void focusInEvent(QFocusEvent *) override
\reimp
static QLocale system()
Returns a QLocale object initialized to the system locale.
Definition qlocale.cpp:2742
The QMainWindow class provides a main application window.
Definition qmainwindow.h:25
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus.
Definition qmenu.h:26
\inmodule QtCore
Definition qobject.h:90
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2823
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
Definition qobject.h:114
The QPageSetupDialog class provides a configuration dialog for the page-related options on a printer.
int exec() override
This virtual function is called to pop up the dialog.
\inmodule QtCore
Definition qpointer.h:18
The QPrintDialog class provides a dialog for specifying the printer's configuration.
int exec() override
\reimp
void init(QPrinter *printer=nullptr)
void _q_navigate(QAction *action)
QPointer< QObject > receiverToDisconnectOnClose
The QPrintPreviewDialog class provides a dialog for previewing and configuring page layouts for print...
~QPrintPreviewDialog()
Destroys the QPrintPreviewDialog.
QPrinter * printer()
Returns a pointer to the QPrinter object this dialog is currently operating on.
QPrintPreviewDialog(QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags())
This is an overloaded member function, provided for convenience. It differs from the above function o...
virtual void open()
Definition qdialog.cpp:499
The QPrintPreviewWidget class provides a widget for previewing page layouts for printer output.
int currentPage() const
Returns the currently viewed page in the preview.
void setPortraitOrientation()
This is a convenience function and is the same as calling {setOrientation(QPageLayout::Portrait)}.
void print()
Prints the preview to the printer associated with the preview.
void fitToWidth()
This is a convenience function and is the same as calling {setZoomMode(QPrintPreviewWidget::FitToWidt...
void zoomIn(qreal zoom=1.1)
Zooms the current view in by factor.
void setViewMode(ViewMode viewMode)
Sets the view mode to mode.
void zoomOut(qreal zoom=1.1)
Zooms the current view out by factor.
qreal zoomFactor() const
Returns the zoom factor of the view.
void setCurrentPage(int pageNumber)
Sets the current page in the preview.
void setLandscapeOrientation()
This is a convenience function and is the same as calling {setOrientation(QPageLayout::Landscape)}.
void fitInView()
This is a convenience function and is the same as calling {setZoomMode(QPrintPreviewWidget::FitInView...
void setZoomFactor(qreal zoomFactor)
Sets the zoom factor of the view to factor.
QPageLayout::Orientation orientation() const
Returns the current orientation of the preview.
\reentrant
Definition qprinter.h:28
@ NativeFormat
Definition qprinter.h:69
bool isValid() const
Definition qprinter.cpp:669
QString docName() const
Returns the document name.
Definition qprinter.cpp:767
QString outputFileName() const
Returns the name of the output file.
Definition qprinter.cpp:687
void setOutputFileName(const QString &)
Sets the name of the output file to fileName.
Definition qprinter.cpp:712
OutputFormat outputFormat() const
Definition qprinter.cpp:565
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
Definition qsizepolicy.h:18
\inmodule QtCore
Definition qsize.h:25
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:129
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
int toInt(bool *ok=nullptr, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
Definition qstring.h:660
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5710
qsizetype size() const
Returns the number of characters in this string.
Definition qstring.h:182
float toFloat(bool *ok=nullptr) const
Returns the string converted to a float value.
Definition qstring.cpp:7688
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:1083
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:7822
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition qstring.cpp:3435
static QString static QString asprintf(const char *format,...) Q_ATTRIBUTE_FORMAT_PRINTF(1
Definition qstring.cpp:7005
The QToolBar class provides a movable panel that contains a set of controls.
Definition qtoolbar.h:23
QAction * addSeparator()
Adds a separator to the end of the toolbar.
Definition qtoolbar.cpp:745
QWidget * widgetForAction(QAction *action) const
QAction * addWidget(QWidget *widget)
Adds the given widget to the toolbar as the toolbar's last item.
Definition qtoolbar.cpp:782
void addAction(QAction *action)
Appends the action action to this widget's list of actions.
Definition qwidget.cpp:3124
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition qtoolbutton.h:20
The QVBoxLayout class lines up widgets vertically.
Definition qboxlayout.h:91
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void setLayout(QLayout *)
Sets the layout manager for this widget to layout.
void setSizePolicy(QSizePolicy)
void setMinimumWidth(int minw)
Definition qwidget.cpp:4119
void setEnabled(bool)
Definition qwidget.cpp:3365
void setContextMenuPolicy(Qt::ContextMenuPolicy policy)
Definition qwidget.cpp:7872
void setFocus()
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qwidget.h:423
virtual void setVisible(bool visible)
Definition qwidget.cpp:8329
void resize(int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qwidget.h:883
void setMaximumWidth(int maxw)
Definition qwidget.cpp:4137
bool visible
whether the widget is visible
Definition qwidget.h:144
QString text
double e
else opt state
[0]
Combined button and popup list for selecting options.
@ AlignRight
Definition qnamespace.h:145
@ AlignVCenter
Definition qnamespace.h:154
@ Widget
Definition qnamespace.h:205
@ NoContextMenu
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
#define SLOT(a)
Definition qobjectdefs.h:51
#define SIGNAL(a)
Definition qobjectdefs.h:52
GLdouble GLdouble GLdouble GLdouble top
GLfloat GLfloat f
GLint GLint bottom
GLbitfield flags
GLuint name
GLuint res
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLuint64EXT * result
[6]
GLenum GLenum GLenum input
static void _q_ppd_initResources()
static void qt_setupActionIcon(QAction *action, QLatin1StringView name)
SSL_CTX int(*) void arg)
#define Q_OBJECT
#define slots
#define Q_INIT_RESOURCE(name)
Definition qtresource.h:14
double qreal
Definition qtypes.h:92
QObject::connect nullptr
QString title
[35]
myObject disconnect()
[26]
ba fill(true)
QFormLayout * formLayout
[0]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent