Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9001981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:30:32+00:00 2026-06-16T00:30:32+00:00

Setting text for QTextEdit : te->setPlainText(Something) ; te->adjustSize(); should wrap around Something only, instead

  • 0

Setting text for QTextEdit:

te->setPlainText(“Something”) ;
te->adjustSize();

should wrap around “Something” only, instead the QTextEdit is expanding to its maximum Width-Height, can’t fix it..
When I select “Something” on run time, only “Something” is highlighted, no added extra white spaces.

Expectations: when text is small enough to fit on one Line, the text edit shouldn’t expand in height, when the text needs to wrap, only the extra line width should be added not the maximum width.

if adjustSize(); is not called, the text will wrap on the width that was set in the .ui in the Creator, won’t dynamically expand horizontally nor vertically..

Some Info:

Horizontal Policy: Expanding
Vertical Policy : MinimumExpanding
minimumSize : 2×22
maximum Size : 300×100
lineWrapMode:
WidgetWidth

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:30:33+00:00Added an answer on June 16, 2026 at 12:30 am

    Yes, looks like there is no easy way to count lines in QTextEdit.
    adjustSize() is made for QWidget and is not reimplemented for QTextEdit, it is based on sizeHint().
    You can use your own method to count lines, f.e.

    1. You can use QFontMetrics to calculate width of every word in your text
    2. You can set height to 22 and increment it until maximumHeight hitted or vertical scrollbar dissapears.
    3. You can get some info from sources of QTextEdit itself and subclass it, reimplementing something (adjustSize()?) there.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a GroupBox at runtime and setting its Text property. Usually, the text
How would i go about setting up a Tkinter Text widget to do something
Below, setting text and setting progress gives me the error.. Multiple markers at this
The Settings/Accessibility Large Text setting sets the text size in some built-in Apps. How
I have an abstract class which contains method for setting header text. It looks
In Android, I am setting the text of a textview to be the answer
I am having trouble setting my ContentProperty to Text. The error I am given
I'm setting up my site to receive info from people via text message. The
Afternoon, I am setting the ID's for a multiple text boxes in my code
In a .aspx web page, by setting a textbox's text property by code in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.