Results 1 to 4 of 4

Thread: Is it possible to set a fixed margin for a QTextEdit?

  1. #1
    Join Date
    Feb 2009
    Posts
    7

    Default Is it possible to set a fixed margin for a QTextEdit?

    Is it possible to set a fixed margin for a QTextEdit so that all loaded html respect the margin even if there is no margin in in the loaded html?

  2. #2
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Is it possible to set a fixed margin for a QTextEdit?

    Have you tried setting a style sheet yet?

    Qt Code:
    1. textEdit->setStyleSheet("margin: 5px");
    To copy to clipboard, switch view to plain text mode 

    See Qt Style Sheets

  3. #3
    Join Date
    Feb 2009
    Posts
    7

    Default Re: Is it possible to set a fixed margin for a QTextEdit?

    Thanks, that works.

    I didn't know you could apply stylesheets to widgets, and I couldn't find a way to do it in the class reference of QTextEdit.

    But I need to use padding, not margin. Margin seems to set the distance to other widgets not to the text in the textEdit.

  4. #4
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Is it possible to set a fixed margin for a QTextEdit?

    If you follow the link above, you will find the "box model" which explains what's margin and padding and what not. If you do use style sheets, you might want to consider placing the style sheet definitions in an external file, so that they are centered in one place and easily modifiable without even having to recompile.

Similar Threads

  1. Change margin on QTextEdit print()
    By Dii in forum Qt Programming
    Replies: 2
    Last Post: 20th May 2008, 22:45
  2. QTextEdit slow to insert text
    By thomaspu in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 12:05
  3. QTextEdit API questions (plain text)
    By Gaspar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 06:03

Tags for this Thread

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.