cyberboy
9th April 2008, 15:43
Hi guys,
I'm currently busy with a printing function for my program. But I can't get some scales right.
The problem is that the text is parsed on one line and when the paper ends it doesn't start at a new line?
This is my current code
#include "print.h"
#include <QPrinter>
#include <QPrintDialog>
#include <QPainter>
void print::printOrder(const QStringList client, const QStringList data){
//generate printing instance
QPrinter printer;
printer.setPageSize(printer.A4);
//create print dialog, pass printer instance
QPrintDialog *pDlg = new QPrintDialog(&printer, this);
pDlg->setWindowTitle(tr("Bestelling printen"));
//debugging
printer.setOutputFileName("rtest.pdf");
if(pDlg->exec())
return;
qDebug("printen");
//generate QPainter instance
QPainter painter;
//pass printer reference to the painter.begin() function
painter.begin(&printer);
painter.setPen(Qt::black);
painter.setFont(QFont("Arial", 14));
painter.drawText(rect(), Qt::AlignLeft, "Bestelling overzicht");
painter.translate(0, 20);
int count = client.size();
for(int i = 1; i < count; i++){
painter.drawText(rect(), Qt::AlignLeft, client.at(i).toLocal8Bit().constData());
painter.translate(0, 20);
}
painter.translate(0, 40);
painter.drawText(rect(), Qt::AlignLeft, "Bestelling");
painter.translate(0, 20);
int countData = data.size();
for(int i = 1; i < countData; i++){
painter.drawText(0, 0, 100, 100, Qt::AlignLeft, data.at(i).toLocal8Bit().constData());
painter.translate(0, 20);
}
painter.save();
}
void print::printWorkingOrder(){
}
The text is parsed in the multiple lines except for the text in the QStringList that is to long to parse on the page and some how doesn't want to be parsed on multiple lines?
Does somebody know how to parse long lines of text within the boundaries of the paper on multiple lines?
Greets,
Cyberboy
I'm currently busy with a printing function for my program. But I can't get some scales right.
The problem is that the text is parsed on one line and when the paper ends it doesn't start at a new line?
This is my current code
#include "print.h"
#include <QPrinter>
#include <QPrintDialog>
#include <QPainter>
void print::printOrder(const QStringList client, const QStringList data){
//generate printing instance
QPrinter printer;
printer.setPageSize(printer.A4);
//create print dialog, pass printer instance
QPrintDialog *pDlg = new QPrintDialog(&printer, this);
pDlg->setWindowTitle(tr("Bestelling printen"));
//debugging
printer.setOutputFileName("rtest.pdf");
if(pDlg->exec())
return;
qDebug("printen");
//generate QPainter instance
QPainter painter;
//pass printer reference to the painter.begin() function
painter.begin(&printer);
painter.setPen(Qt::black);
painter.setFont(QFont("Arial", 14));
painter.drawText(rect(), Qt::AlignLeft, "Bestelling overzicht");
painter.translate(0, 20);
int count = client.size();
for(int i = 1; i < count; i++){
painter.drawText(rect(), Qt::AlignLeft, client.at(i).toLocal8Bit().constData());
painter.translate(0, 20);
}
painter.translate(0, 40);
painter.drawText(rect(), Qt::AlignLeft, "Bestelling");
painter.translate(0, 20);
int countData = data.size();
for(int i = 1; i < countData; i++){
painter.drawText(0, 0, 100, 100, Qt::AlignLeft, data.at(i).toLocal8Bit().constData());
painter.translate(0, 20);
}
painter.save();
}
void print::printWorkingOrder(){
}
The text is parsed in the multiple lines except for the text in the QStringList that is to long to parse on the page and some how doesn't want to be parsed on multiple lines?
Does somebody know how to parse long lines of text within the boundaries of the paper on multiple lines?
Greets,
Cyberboy