Results 1 to 16 of 16

Thread: QTextEdit text size

  1. #1
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default QTextEdit text size

    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!!

  2. #2
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTextEdit text size

    Please help anyone?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTextEdit text size

    Quote Originally Posted by Tiansen View Post
    I tried many ways to try to solve this
    Are we expected to guess what you have tried?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTextEdit text size

    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.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTextEdit text size

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTextEdit text size

    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.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTextEdit text size

    Quote Originally Posted by Tiansen View Post
    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)?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTextEdit text size

    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.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTextEdit text size

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: QTextEdit text size

    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.

  11. #11
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTextEdit text size

    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!

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTextEdit text size

    I'd start with QPrinter::setResolution().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTextEdit text size

    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.

  14. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTextEdit text size

    Quote Originally Posted by Tiansen View Post
    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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. #15
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTextEdit text size

    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.

  16. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTextEdit text size

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Adjust the initial size of a QTextEdit in a layout
    By hecinho in forum Qt Programming
    Replies: 0
    Last Post: 26th November 2009, 15:58
  2. Replies: 12
    Last Post: 30th May 2009, 14:29
  3. QTextEdit + paste rich text as plain text only
    By Yong in forum Qt Programming
    Replies: 2
    Last Post: 6th February 2008, 16:45
  4. Size of the cursor in QTextEdit
    By Ankitha Varsha in forum Qt Programming
    Replies: 3
    Last Post: 22nd January 2008, 12:32
  5. Replies: 1
    Last Post: 24th October 2006, 16:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.