Results 1 to 4 of 4

Thread: Why didn't images with text alignment in QTextEdit?

  1. #1
    Join Date
    Apr 2016
    Posts
    37
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    2

    Default Why didn't images with text alignment in QTextEdit?

    hi all.

    I insert a text and images to QTextEdit , but I found no alignment.
    69f68f88gw1f3b1e1io1aj207g01b0sp.jpg

    I try setAlignment(Qt::AlignBottom) in QTextEdit , but no change.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,345
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: Why didn't images with text alignment in QTextEdit?

    It looks to me like your text is aligned at the bottom. You are forgetting that Western characters have descenders - characters like 'y', 'g', and 'p' extend below the baseline of other characters like 'w', 'e', etc. If you make a text string for testing that contains characters with decenders, I think you will see that these characters do extend to the bottom of the text edit (minus whatever margin the widget is using).

    Use QFontMetrics::descent() to obtain the number of pixels used for descenders in your font.

  3. The following user says thank you to d_stranz for this useful post:

    tiaoweiliao (28th April 2016)

  4. #3
    Join Date
    Apr 2016
    Posts
    37
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    2

    Default Re: Why didn't images with text alignment in QTextEdit?

    Thank you, I got it.

    How will the characters like 'y', 'g' at the bottom with image bottom alignment?

    ignore characters like 'w', 'e'.

  5. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,345
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: Why didn't images with text alignment in QTextEdit?

    Sorry, I don't understand. Are you saying that you want your text to be bottom aligned with the image of the Chinese characters? You will probably get something better looking if you use Qt:: AlignVCenter on both of them. The it will not matter what the text is, both the text and the image will be vertically centered in the boxes.

Similar Threads

  1. Replies: 1
    Last Post: 11th March 2014, 12:20
  2. Replies: 1
    Last Post: 21st November 2009, 21:38
  3. Replies: 2
    Last Post: 30th December 2008, 22:35
  4. QTextEdit Alignment won't stick
    By jrideout in forum Qt Programming
    Replies: 3
    Last Post: 10th January 2007, 16:54
  5. QTextEdit Alignment
    By vijay anandh in forum Qt Programming
    Replies: 1
    Last Post: 2nd May 2006, 08:44

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
  •  
Qt is a trademark of The Qt Company.