PDA

View Full Version : QTextEdit text size



Tiansen
25th October 2010, 07:53
I am using QTextEdit to show some contents. I have following problem: if I print contents of QTextEdit, text is significantly smaller. I guess that prioblem is in different DPI between screen and printer. I tried many ways to try to solve this but I cannot find a way that would not affect printed size too. Can you please point me into right direction to achieve this?

Thanks!!

Tiansen
27th October 2010, 10:42
Please help anyone?

wysota
27th October 2010, 10:46
I tried many ways to try to solve this
Are we expected to guess what you have tried?

Tiansen
27th October 2010, 13:33
Well, for example I tried with QTextEdit_object->zoomOut(10) and that does not seem to have any effect.

I load QTextDocument object into QTextEdit.

wysota
27th October 2010, 13:58
You are printing the document and not the widget so I'd be really suprised if manipulating the widget would have changed the printout. If you change the palette of the text edit widget to have red colour as the background, it won't make your printout have red background too.

Tiansen
28th October 2010, 06:44
You are printing the document and not the widget so I'd be really suprised if manipulating the widget would have changed the printout. If you change the palette of the text edit widget to have red colour as the background, it won't make your printout have red background too.

I understand that. I DON'T want to change printout. I want to change how text is presented on SCREEN, i.e. make it smaller.

wysota
28th October 2010, 10:00
I understand that. I DON'T want to change printout. I want to change how text is presented on SCREEN, i.e. make it smaller.

Oh, good that in post #6 you finally decided to tell us what was wrong (we're still waiting for the "tried many things" part). Did you try changing the font size of the widget (not of the document)?

Tiansen
28th October 2010, 10:54
In first post I mentioned:

"I cannot find a way that would not affect printed size too"

Well, maybe it was not written explicitly enough.
I tried to use zoomOut() function on QTextEdit. I think this would be most appropriate solution, that would affect only widget. But it does not change anything.
I don't want to have fixed font size in widget, so I think zoomOut() function would be best, because I want to resize text so that I still have different font sizes and weights (like captions).
I remember I tried many things a month ago (with no success) and I don't actually remember every details. Now I'm experimenting with zoomOut() function like I said, but it does not work. Any additional suggestion would be more than welcome.

wysota
28th October 2010, 11:02
With zoomOut() you'd have exactly the same problem as with a fixed font size - you have to use an arbitrary number that may work with your current settings but not with someone else's desktop/printer combination. I think the proper approach is to get the looks you want in the text edit (ignoring the printout) and then adjust the printer's object (with things such as scaling and DPI) to get the printout you want.

tbscope
28th October 2010, 11:05
This is one of those problems that benefits from a model/view structure. The model being the document (the text), the view being either a widget on the screen, or the printer.

Tiansen
29th October 2010, 07:45
I would be very thankful if you could point me in right direction in how to achieve that scaling of printer object. I cannot find out how to do that!

wysota
29th October 2010, 09:45
I'd start with QPrinter::setResolution().

Tiansen
29th October 2010, 11:19
Well, correct me if I'm wrong but I don't think that's correct approach. I want to always print at HighResolution regardless of size of that what I'm printing.

wysota
29th October 2010, 11:24
I want to always print at HighResolution regardless of size of that what I'm printing.
So print at high resolution, I'm not stopping you from doing that - you have three parameters, the resolution of the printer, resolution of the screen and size of the font. Find a combination of the three that works for you. Do you want us to take a calculator and calculate it for you or is there some other thing you are asking us to do?

Tiansen
29th October 2010, 11:45
OK. Now. I want to print at 300 DPI, my screen resolution is what it is - fixed. Now I have to set font size so, that I get proper size, when I print on paper. I am only wondering, why does not zoomOut() function of QTextEdit work, so I can have proper font size for printing and proper size on screen (zoomed out) too.

wysota
29th October 2010, 11:56
Probably because zoomOut() is no-op when the effective point size becomes negative (since the default font size is probably somewhere around 9, if you substract 10 it becomes -1). Note that calling zoomOut() is effectively identical to calling setFont() with a fixed font size which is bound to give the effect other than you want if someone has a different printer or a different system font which is what you opted to avoid at the beginning of this thread.