How to distribute columns of QTableWidget evenly using code?
Hi every one!
Can any body please guide me how to distribute columns of QTableWidget evenly using code?
I want the QTableWidget to be of maximum width of 360 pixels. but when the number of columns go beyond 3, a scroll bar appears.
Now what I want is that the columns distribute themselves (by reducing their widths) to maintain the width of 360 & prevent the horizontal scroll bar to appear.
Please someone guide me..
Re: How to distribute columns of QTableWidget evenly using code?
Did you already try below as per the documentation -
The QTableWidget has the resizeColumnsToContents() method that resizes the columns. The below resizes the last column to fit to the right edge of the table.
QHeaderView *HorizonHdr = ui.tableWidget->horizontalHeader();
HorizonHdr->setStretchLastSection(true);
One more method -
QHeaderView *HorizonHdr = ui->tableWidget->horizontalHeader();
HorizonHdr->setResizeMode(QHeaderView::Stretch);
Re: How to distribute columns of QTableWidget evenly using code?
Thanks kusumk...
It solved the problem..