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 8482693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:53:06+00:00 2026-06-10T19:53:06+00:00

While filling tableWidget with some text I’ve used self.ui.tableWidget.resizeRowToContents for every row. After that

  • 0

While filling tableWidget with some text I’ve used self.ui.tableWidget.resizeRowToContents for every row.
After that and: self.ui.tableWidget.setSortingEnabled(1) ,sorting is working as expected but rows are not resize to content anymore, in fact they preserve previous height.

name                              name v                 name v
---------                         ---------              ---------
text2                             text1line1             text1line1
---------  after sort is clicked: ---------   expected:  text1line2
text1line1                                               text1line3
text1line2                        text2                  ---------
text1line3                                               text2
---------                         ---------              ---------

My idea is to catch signal when sorting in header is clicked, and go again with self.ui.tableWidget.resizeRowToContents through all rows.
How to catch that signal?

  • 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-10T19:53:08+00:00Added an answer on June 10, 2026 at 7:53 pm

    There’s no need to call resizeRowToContents for every row that is added.

    Instead, after the table is filled, call the resizeRowsToContents slot, which will resize all the rows at once.

    You can then connect the same slot to the sortIndicatorChanged signal, so that the rows are resized whenever the columns are sorted:

    # ... fill table, then:
    self.ui.tableWidget.setSortingEnabled(True)
    self.ui.tableWidget.resizeRowsToContents()
    self.ui.tableWidget.horizontalHeader().sortIndicatorChanged.connect(
        self.ui.tableWidget.resizeRowsToContents)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is a problem in VBA text box while filling input mask property: I
I have a TableAdapter filling a DataSet , and for some reason every select
I have used vector::emplace_back in order to avoid constructing temporal objects while filling a
I have an app that would benefit from google-style autocompletion while filling in an
I have dropdownlist,which get filled from table1.That table1 has Zero value.While filling the dropdown,want
I want to know how can i fill only certain columns while filling the
while looking at some code I stumbled onto: throw /*-->*/new std::exception (//... and I
While a user is filling out one form, I want them to be able
While building my assembler for the x86 platform I encountered some problems with encoding
I can't understand why does vector empty after it's filling. The code is: bool

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.