如何(使用打印机)打印 QML 对象? [英] How to print(with the printer) a QML object?
本文介绍了如何(使用打印机)打印 QML 对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用 Qt Quick 设计了一个销售收据,我想用打印机打印它.
I have designed a sales receipt with Qt Quick and I want to print it with the printer.
我该怎么做?
这是我的main.cpp
QtQuick2ApplicationViewer viewer;
viewer.setMainQmlFile(QStringLiteral("qml/Caisse-MBM/main.qml"));
viewer.showFullScreen();
推荐答案
你可以使用 QQuickView::grabWindow()
得到一个 QImage
然后做任何你想做的事用它,打印它,保存它......
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.
这篇关于如何(使用打印机)打印 QML 对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文