Frage

I have designed a sales receipt with Qt Quick and I want to print it with the printer.

How can I do this?

Here is my main.cpp

QtQuick2ApplicationViewer viewer;
viewer.setMainQmlFile(QStringLiteral("qml/Caisse-MBM/main.qml"));
viewer.showFullScreen();
War es hilfreich?

Lösung

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();

Afterwards you can follow this post to get the image to print.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top