Doc/Printsupport: misc fixes
- use new signal/slot syntax - fix includes - adjust style Change-Id: Icdc9b33e72e24c39cc6e96b4f2cafa78e179efbf Reviewed-by: Paul Wicking <paul.wicking@qt.io>
This commit is contained in:
parent
c7f59cad19
commit
b4db334c03
@ -48,7 +48,11 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtGui>
|
||||
#include <QtWidgets>
|
||||
#include <QtPrintSupport/qtprintsupportglobal.h>
|
||||
#if QT_CONFIG(printdialog)
|
||||
#include <QPrinter>
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
@ -48,9 +48,14 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtGui>
|
||||
#include "object.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QtPrintSupport/qtprintsupportglobal.h>
|
||||
#if QT_CONFIG(printdialog)
|
||||
#include <QPrinter>
|
||||
#endif
|
||||
|
||||
Object::Object(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
|
@ -48,7 +48,6 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtGui>
|
||||
#include <QtWidgets>
|
||||
#include <QtPrintSupport/qtprintsupportglobal.h>
|
||||
#if QT_CONFIG(printdialog)
|
||||
@ -61,11 +60,12 @@ class Window : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Window() {
|
||||
Window()
|
||||
{
|
||||
myWidget = new QPushButton("Print Me");
|
||||
connect(myWidget, SIGNAL(clicked()), this, SLOT(print()));
|
||||
connect(myWidget, &QPushButton::clicked, this, &Window::print);
|
||||
myWidget2 = new QPushButton("Print Document");
|
||||
connect(myWidget2, SIGNAL(clicked()), this, SLOT(printFile()));
|
||||
connect(myWidget2, &QPushButton::clicked, this, &Window::printFile);
|
||||
editor = new QTextEdit(this);
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
@ -76,8 +76,9 @@ public:
|
||||
}
|
||||
|
||||
private slots:
|
||||
void print() {
|
||||
#if !defined(QT_NO_PRINTER)
|
||||
void print()
|
||||
{
|
||||
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
|
||||
printer.setOutputFileName("test.pdf");
|
||||
@ -85,8 +86,8 @@ private slots:
|
||||
//! [0]
|
||||
QPainter painter;
|
||||
painter.begin(&printer);
|
||||
double xscale = printer.pageRect().width()/double(myWidget->width());
|
||||
double yscale = printer.pageRect().height()/double(myWidget->height());
|
||||
double xscale = printer.pageRect().width() / double(myWidget->width());
|
||||
double yscale = printer.pageRect().height() / double(myWidget->height());
|
||||
double scale = qMin(xscale, yscale);
|
||||
painter.translate(printer.paperRect().x() + printer.pageRect().width()/2,
|
||||
printer.paperRect().y() + printer.pageRect().height()/2);
|
||||
@ -98,8 +99,9 @@ private slots:
|
||||
#endif
|
||||
}
|
||||
|
||||
void printFile() {
|
||||
#if QT_CONFIG(printdialog)
|
||||
void printFile()
|
||||
{
|
||||
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
|
||||
//! [1]
|
||||
QPrinter printer;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user