PDA

View Full Version : export qtableview in PDF



phapha
30th October 2011, 13:47
Hi all,
I'am writing an application that takes data from a sqlite database and show it thanks to a qtableview. I would like now to add a button export which export the data displayed in this view to a PDF file.
Here is the slot I wrote:



//Exporter la liste des utilisateurs
void PageUser::genPdfUser()
{
QString filename="users.pdf";
//Paramètres d'impression
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFileName(filename);
printer.setPaperSize(QPrinter::A4);
printer.setOutputFormat(QPrinter::PdfFormat);

QPainter painter(&printer);
painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
m_userView->render( &painter );
painter.end();
}


It doesn't work because when I click the button, I have no reaction. Hindly help me to corect it.

thanks

stampede
30th October 2011, 16:10
It doesn't work because when I click the button, I have no reaction.
Is this method even called ?

ChrisW67
30th October 2011, 23:04
What is the current working directory of the program? Probably not where you think it is (often the "Program Files\X" directory on Windows).
Where is "user.pdf" going to be written? In the current working directory of the program.
Can it be written there? Possibly not.
Where are you looking for "user.pdf"? Possibly not in the current working directory of the program.