0
votes

In my project I have some own widgets. When I click on a toolbar-button to print, I want to print the widgets in a specific layout (landscape-orientation).

I tried it with a new QWidget with a layout, and in this layout add my widgets. But when I do this, my widget disappear from my mainwindow.

How can I print my widget without disappearing and my own layout?

1
If you want us to help you, you must provide a minimal reproducible exampleeyllanesc
What do you mean saying "print widgets"?vahancho
Widgets are unique objects, and can only be under one parent at a time. You don't provide much detail, but it's probably best to duplicate the widgets for printing. If you use separate models and views, then models don't need to be duplicated.hyde

1 Answers

1
votes

I had asked something similar - Printing complex widgets

and basically ended up in some design, where I set up an invisible copy of the whole widget and caused it to resize on the best size for the print job - take portrait and landscape printing into consideration!

I had to add code to paint- and resize- related methods of my custom widgets, where depending if I was printing or painting to screen, I modified palettes, font sizes, style sheets etc. Modifiying palettes might be necessary if your printer is black/white only. Or if your application has a dark background, you might want to flip colours.

This was quite a tedious job, but you will notice, that customers often don't want a screen hardcopy but something better.