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

前端 未结 1 1411
野趣味
野趣味 2021-01-01 04:01

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



        
相关标签:
1条回答
  • 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.

    0 讨论(0)
提交回复
热议问题