How to print (with a printer) a QML object?

I developed a sales receipt with Qt Quick and want to print it using a printer.

How can i do this?

Here is my main.cpp

QtQuick2ApplicationViewer viewer; viewer.setMainQmlFile(QStringLiteral("qml/Caisse-MBM/main.qml")); viewer.showFullScreen(); 
+5
qt printing qml qt-quick qtquick2
May 28 '13 at 12:54
source share
1 answer

You can use QQuickView::grabWindow() to get a QImage , and then do whatever you want with it, print it, save it ...

 QImage image = view->grabWindow(); 

Subsequently, you can follow this message to get an image for printing. A.

+5
May 28 '13 at 13:23
source share



All Articles