本文整理汇总了Java中com.trolltech.qt.gui.QPainter.drawText方法的典型用法代码示例。如果您正苦于以下问题:Java QPainter.drawText方法的具体用法?Java QPainter.drawText怎么用?Java QPainter.drawText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.trolltech.qt.gui.QPainter
的用法示例。
在下文中一共展示了QPainter.drawText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PrintTableWidget
import com.trolltech.qt.gui.QPainter; //导入方法依赖的package包/类
public static void PrintTableWidget(QPrinter printer, QPainter painter, String title, QTableWidget tw, String widthFields[][]){
int lW;
int lH = 20;
int lX1 = 20;
int lY = 90;
int nroPage = 1;
int height = painter.paintEngine().paintDevice().height(); // alto de la página
int nroPerPage = (height == 992 ? 44 : 32); //922
int totalPage = (int)(tw.rowCount() / nroPerPage) + 1;
QPen pen = new QPen();
pen.setWidth(1);
pen.setColor(QColor.black);
painter.setPen(pen);
QFont fnt = new QFont("Arial",10);
painter.setFont(fnt);
//992 salto de página letter portrait
for(int i=0; i<tw.rowCount(); i++){
if(lY>=(height - 22)){
printer.newPage();
PrintHeader(painter, title, widthFields, ++nroPage, totalPage);
fnt.setPointSize(10);
painter.setFont(fnt);
lX1 = 20;
lY = 90;
}
for(int j=0; j<widthFields.length; j++){
lW = Integer.parseInt(widthFields[j][0]);
painter.drawRect(lX1 , lY, lW , lH);
painter.drawText(lX1+2, lY, lW-4, lH, Qt.AlignmentFlag.AlignVCenter.value() | Integer.parseInt(widthFields[j][2]), tw.item(i, j).text());
lX1 += lW;
}
//painter.drawText(40, lY-5, "Y:" + lY); // para chequear en que coordenada hacer el salto de página
lX1 = 20;
lY += lH;
}
}
示例2: on_btnImprimir_Clicked
import com.trolltech.qt.gui.QPainter; //导入方法依赖的package包/类
/**
*
*/
public void on_btnImprimir_Clicked()
{
QPrinter printer = new QPrinter(QPrinter.PrinterMode.HighResolution);
printer.setOutputFormat(QPrinter.OutputFormat.PdfFormat);
printer.setOutputFileName("/home/pablo/temp/citacion.pdf");
printer.setPageSize(QPrinter.PageSize.A6);
//printer.setFullPage(true);
printer.setPageMargins(2,2,2,2,QPrinter.Unit.Millimeter);
QPainter painter = new QPainter();
if(!painter.begin(printer)){
QMessageBox.critical(this, "Escritura de archivo", "Error al abrir el archivo PDF para escritura.");
return;
}
QPen pen = new QPen();
pen.setWidth(1);
pen.setColor(QColor.black);
painter.setPen(pen);
QFont fnt = new QFont("Tahoma",10);
painter.setFont(fnt);
painter.drawText( 20, 100, "COMPROBANTE DE CITACION NUMERO: ");
//painter.drawText( 20, 250, "Imp.:"+Utils.ObtenerFechaHora().toDateTime().toString("dd-MM-yyyy HH:mm ")+DBUtils.getTableField(String.format("SELECT eps_user FROM minitis.prestsol_enc WHERE eps_id=%1$s", ui.leID.text())).toString());
painter.drawText( 20, 250, "Imp.:"+Utils.ObtenerFechaHora()+" "+DBUtils.getTableField(String.format("SELECT eps_user FROM miniris.prestsol_enc WHERE eps_id=%1$s", ui.leID.text())).toString());
painter.drawText( 20, 400, "Ambulatorio");
painter.drawText( 20, 550, "Citación");
painter.drawText( 20, 700, ui.cmbSSal.currentText());
painter.drawText( 20, 850, "DERIVADO DE: "+ui.cmbTDer.currentText()+". "+ui.cmbDeri.currentText());
fnt.setFamily("C39HrP48DhTt");
fnt.setPointSize(42);
painter.setFont(fnt);
painter.drawText(3400, 550, "*"+ui.leID.text()+"*");
fnt.setFamily("Tahoma");
fnt.setPointSize(10);
painter.setFont(fnt);
painter.drawLine( 0, 950, 4700,950);
painter.drawText(20,1150, ui.leRUN.text().isEmpty()?ui.leFich.text():ui.leRUN.text()+" "+ui.lePaciente.text());
//painter.drawText(20,1300, "Edad: "+ui.lblEdad.text()+" Sexo: "+ui.lblSexo.text()+" Prioridad: "+ui.cmbNUrg.currentText()+" "+ui.lblFHCit.text());
painter.drawLine( 0,1400, 4700,1400);
fnt.setPointSize(8);
painter.setFont(fnt);
int lY = 1400;
for(int row=0;row<ui.twPrestaciones.rowCount();row++)
painter.drawText(20,lY+=150, ui.twPrestaciones.item(row,1).text()+" x "+ui.twPrestaciones.item(row,3).text()+" "+ui.twPrestaciones.item(row,2).text());
lY += 100;
painter.drawLine( 0,lY,4700,lY);
fnt.setPointSize(13);
painter.setFont(fnt);
lY += 200;
painter.drawText(20,lY,"CITADO EL: "+ui.cwFecha.selectedDate().toString("dd-MM-yyyy")+" A LAS: "+ui.twHoras.item(ui.twHoras.currentRow(),1).text()+" HRS.");
painter.end();
Utils.ShowPDF(printer.outputFileName());
//Citacion.Printer(ui.twHoras);
}
示例3: PrintHeader
import com.trolltech.qt.gui.QPainter; //导入方法依赖的package包/类
/**
PrintHeader
Descripción: Imprime en el painter la cabezera de un informe.
Parámetros :
painter : Objeto QPainter en donde se dibujará (argumento utilizado por referencia)
title : String con el título del informe
*/
public static void PrintHeader(QPainter painter, String title, String header[][], int nroPage, int totalPage){
//QRect rect = new QRect(10,10,350,150);
QPen pen = new QPen();
pen.setWidth(1);
pen.setColor(QColor.black);
painter.setPen(pen);
int width = painter.paintEngine().paintDevice().width(); // ancho de la página
int height = painter.paintEngine().paintDevice().height(); // alto de la página
QFont fnt = new QFont("Arial",8);
//fnt.setLetterSpacing(QFont::PercentageSpacing,104);
int lX = 20; // Para el margen izquierdo
//painter.drawImage(rect,QImage(String(":/images/resources/logo.png")));
//painter.drawRect(lX, 10, width - (lX * 2), 60);
painter.setFont(fnt);
painter.drawText(lX+4 , 30, "EIMS");
painter.drawText(width - lX - 60 , 30, QDate.currentDate().toString("dd-MM-yyyy"));
painter.drawText(lX+4, 50, "RIS");
painter.drawText(width - lX - 60 , 50, QTime.currentTime().toString("HH:mm:ss"));
fnt.setPointSize(14);
fnt.setBold(true);
painter.setFont(fnt);
painter.drawText(0, 20, width, 40, 5, title);
pen.setWidth(2);
painter.setPen(pen);
painter.drawLine(lX, 65, width - lX, 65);
pen.setWidth(1);
painter.setPen(pen);
fnt.setPointSize(12);
fnt.setBold(false);
painter.setFont(fnt);
int lX1 = lX;
int lW;
for(int i=0; i<header.length; i++){
lW = Integer.parseInt(header[i][0]);
painter.fillRect(lX1 , 70, lW , 20, QColor.lightGray);
painter.drawRect(lX1 , 70, lW , 20);
painter.drawText(lX1+2, 70, lW-4, 20, 0, header[i][1]);
lX1 += lW;
}
// Para el footer de la página
fnt.setPointSize(8);
painter.setFont(fnt);
pen.setWidth(2);
painter.setPen(pen);
painter.drawLine(lX, height - 14, width - lX, height - 14);
pen.setWidth(1);
painter.setPen(pen);
painter.drawText(lX, height - 10, width - lX, 20, 5, "EIMS - Sistema de Información Radiológica");
painter.drawText(width - lX - 60 , height - 10, 100, 20, 0, "Pág.: " + nroPage+"/"+totalPage);
}