Rafaelpsmed
11th February 2015, 01:14
Hi
I have 2 qplaintextedit with 2 buttons. Each button will pass the text from one qplaintextedit to a string x and call the function printreport and the then print (thats the idea at least)
I'm trying to implement a QPreviewDialog like this:
void::mainwindow::printreport(QString x)
{
QPrinter printer;
printer.setPageSize(QPrinter::A4);
printer.setOrientation(QPrinter::Portrait);
printer.setPageMargins (10,10,10,10,QPrinter::Millimeter);
QPrintPreviewDialog preview(&printer);
connect(&preview, SIGNAL(paintRequested(QPrinter *)),this, SLOT(printpage(QPrinter*, QString x)));
preview.showMaximized();
preview.exec();
}
void mainwindow::printpage(QPrinter *printer, QString x)
{
QPainter painter(printer);
QRect reccomum(0,0,720,30);
painter.drawText(100, 100, "Hello World! 123");
painter.drawText(reccomum,Qt::AlignLeft,x);
}
This doesn't work. The printpreview dialog shows a gray area. I get this error message:
QObject::connect: No such slot mainwindow:: printpage(QPrinter*, QString x) in ..\Receitas\mainwindow.cpp:432
QObject::connect: (receiver name: 'mainwindow')
When i delete QString x both from void mainwindow:: printpage and from the signal:slot (that is: leaving only SLOT(print(QPrinter*)) the page is created, but without the text from the qplaintextedit.
My question is: how can i implement this printpage slot passing the string x?
Thanks in advance.
I have 2 qplaintextedit with 2 buttons. Each button will pass the text from one qplaintextedit to a string x and call the function printreport and the then print (thats the idea at least)
I'm trying to implement a QPreviewDialog like this:
void::mainwindow::printreport(QString x)
{
QPrinter printer;
printer.setPageSize(QPrinter::A4);
printer.setOrientation(QPrinter::Portrait);
printer.setPageMargins (10,10,10,10,QPrinter::Millimeter);
QPrintPreviewDialog preview(&printer);
connect(&preview, SIGNAL(paintRequested(QPrinter *)),this, SLOT(printpage(QPrinter*, QString x)));
preview.showMaximized();
preview.exec();
}
void mainwindow::printpage(QPrinter *printer, QString x)
{
QPainter painter(printer);
QRect reccomum(0,0,720,30);
painter.drawText(100, 100, "Hello World! 123");
painter.drawText(reccomum,Qt::AlignLeft,x);
}
This doesn't work. The printpreview dialog shows a gray area. I get this error message:
QObject::connect: No such slot mainwindow:: printpage(QPrinter*, QString x) in ..\Receitas\mainwindow.cpp:432
QObject::connect: (receiver name: 'mainwindow')
When i delete QString x both from void mainwindow:: printpage and from the signal:slot (that is: leaving only SLOT(print(QPrinter*)) the page is created, but without the text from the qplaintextedit.
My question is: how can i implement this printpage slot passing the string x?
Thanks in advance.