Relative re-sizing of QTableWidget's columns
	
	
		I am using a QTableWidget with 4-5 columns in a dialog. The dialog is resizable, I want table widget columns to resize according to dialog size i.e. if I increase dialog width, columns which are initially set with large width should expand more than the columns which were set with less width.
In short, I want relative resizing like column1 should occupy 20%, column2 occupy 50% of my table width (which increases with dialog width) and so on.
How this can be achieved for QTableWidget in Qt ? 
Any solution, pointers or hints would be very  helpful.
	 
	
	
	
		Re: Relative re-sizing of QTableWidget's columns
	
	
		A rough solution
	Code:
	
{
public:
    explicit TableWidget
(QWidget * parent 
= 0)     {
        setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        horizontalHeader()->setStretchLastSection(true);
    }
 
    TableWidget
(int rows, 
int columns, 
QWidget *parent 
= 0)    {
        setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        horizontalHeader()->setStretchLastSection(true);
    }
 
protected:
    {
        if(model() and model()->columnCount())
            for(int column = 0; column < model()->columnCount(); column++)
                setColumnWidth(column, event->size().width() / model()->columnCount());
    }
};