Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clip left side of column cell when resizing a pyqt tableview

Tags:

qt

tableview

pyqt

In a tableview or tablewidget of pyqt (and qt in general), if you resize column cells that have no wrap on them, the right side of the cell value will be clipped (and replaced with ellipses ...) regardless of whether the cell value is left or right aligned.

The effect is as follows:

The long and winding road.  => The long and windi...

Is it possible to force the table to resize the cells while clipping the left side of the cell value, instead?

The effect I want is as follows:

The long and winding road.  => ...ng and winding road.

I want this so that if I right align a line of text, and then resize the cell, I want to always see what comes at the very end of the line.

Any help would be appreciated.

like image 468
Lozzer Avatar asked Dec 11 '25 20:12

Lozzer


1 Answers

You can use setTextElideMode to set where the "..." is placed. In your case (using C++):

ui->tableWidget->setTextElideMode(Qt::ElideLeft);

Note that the elide mode affects all columns.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!