[PyQt] Detecting if a column has been resized by the user; auto-stretching columns.

Anonymous junk_and_mail at yahoo.com
Wed Dec 3 17:10:00 GMT 2008


--- On Mon, 12/1/08, simozack <simozack at yahoo.it> wrote:

> From: simozack <simozack at yahoo.it>
> Subject: Re: [PyQt] Detecting if a column has been resized by the user; auto-stretching columns.
> To: junk_and_mail at yahoo.com
> Date: Monday, December 1, 2008, 2:09 AM
> 2008/11/28, Anonymous <junk_and_mail at yahoo.com>:
> > Concerning QTableWidget, i need to figure out all of
> the above. I couldn't find anything in the
> documentation, neither by Googling, that would allow me or
> provide insight on how to do any of these, so i come here as
> a last resort. Also, does it require subclassing a delegate
> or item in order to have rows auto-resize based on their
> content? Or is it possible to pass the size of the content
> to the cell without subclassing anything?
> >
> > Any insight is appreciated.
> 
> Look at the "resizeColumnsToContents" method of
> the QTableWidget object.
> 
> Simone

Thanks for the response, but i saw that in the documentation before asking, and it's not what i'm looking for. The columns for my purpose do not need to be fully stretched out, i just need the last column in the view to auto-stretch if there is space for it to take up. Since QTableWidget does not by default support HTML, i had attempted two methods into getting it to display HTML. The first was subclassing QItemDelegate and QTableWidgetItem. The other was setting a QLabel as a table cell's widget. However, both of them have undesirable consequences which i have been trying to solve. The common undesirable consequence is that both attempts do not give the proper (i believe) size hints for the table cell, so double-clicking on the row's or column's edge causes an inaccurate resize.

In attempting to detect if a column has been resized by the user, i thought 

   tableWidget.__class__.columnResized = self.columnResized

would help, but it didn't. The reason why i need to detect if the user resized the column is so i can resize all the rows.


      


More information about the PyQt mailing list