Qt printer
-
hi,
how to send qml gui (as image) to qt-c++ ........because i want printing this gui ...please help me
-
why do open up a new thread instead of continuing the "old one":http://qt-project.org/forums/viewthread/28935/ ?
I already gave an answer there...what's unclear to you of this solution?
-
i can't understand your example...because i don't know where and how to send my qml gui (like hello.qml file) to this qt c++ function...
i have hello.qml gui
like,Rectangle{
id:gui
width:100
height:100
color:"red"
Text{
id:text
text:"Hello World"
font.bold:true
anchors.centerin:parent
}
MouseArea{
anchors.fill: parent
onClicked: myObject.print_pdf();
}
}i have created Qdeclarative view for sending data to c++ function..
please see the mousearea function i have created onclicked finction,
in this onclicked function i want to send hello.qml to c++(print_pdf() function) ...this function is in c++)note: this myObject is Qdeclarative element name
my question is in this onclicked function how to send this hellow.qml to print_pdf function
-
since you already use a QDeclarativeView (derives QWidget) use it in my example. DOnt print the qml-file, instead print the view that renders the qml-file:
@
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(filename);
QPrintDialog printDialog(&printer);
if(printDialog.exec() == QDialog::Accepted)
{
ui->declarativeView->render(&printer);
}
@or if you use Qt 5 you can use QPdfWriter [qt-project.org]:
@
QPdfWriter pdfWriter("C:/mypdf.pdf");
ui->declarativeView->render(&pdfWriter);
@