Different widths for each column in different row in QTableWidget - Qt5
Hi,
I am creating a QTableWidget with multiple rows and columns.
And inserting custom QWidgets into the table.
These custom widgets are having diff. widths.
I am giving the below settings for the QTableWidget:
QTableWidget *m_pTimelineTable = new QTableWidget();
m_pTimelineTable->setRowCount(m_masterLayout.sRowCount);
m_pTimelineTable->setColumnCount(m_masterLayout.sColCount);
m_pTimelineTable->horizontalHeader()->hide();
m_pTimelineTable->verticalHeader()->hide();
m_pTimelineTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContent s);
m_pTimelineTable->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContent s);
m_pTimelineTable->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysO ff);
m_pTimelineTable->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff );
...
...
//Custom Widget
MyView *mView = new MyView(); //Inherited from QWidget
int iCustomWidth = 600;
mView->setGeometry(0,0,iCustomWidth,250);
//This iCustomWidth will be different for each custom widget
...
...
m_pTimelineTable->setCellWidget((*bIterator).row_num, (*bIterator).col_num, mView);[/I][/I]
Now, all CustomWidgets in each cell of the QTableWidget is having the same width.
Anyone, could you please suggest me to get the diff. widths of custom widgets in each cell ...
Thanks
Kalyan
Re: Different widths for each column in different row in QTableWidget - Qt5
Do you want to set the cell width or widget width?
or
Do you want to set the cell width and fit the widget to the cell width ?
All cells in a column will have same width, you can try setting column span for the cell.
Re: Different widths for each column in different row in QTableWidget - Qt5
Quote:
Originally Posted by
Santosh Reddy
Do you want to set the cell width or widget width?
or
Do you want to set the cell width and fit the widget to the cell width ?
All cells in a column will have same width, you can try setting column span for the cell.
Yes...exactly...I am looking for "set the cell width and fit the widget to the cell width".
If not with QTableWidget, is there any other widget/layout to achieve this ?
Thanks
Re: Different widths for each column in different row in QTableWidget - Qt5
For different width cells you will have to use column span.
Re: Different widths for each column in different row in QTableWidget - Qt5