hiranes
hiranes

Reputation: 17

QT QTableWidget not appearing in QTabWidget

I have an application which uses multiple tabs. I used QTabWidget. On some tabs I needed to show tables, so I used QTableWidget.

The code snippet is:

QWidget *qwgt = qPreviewTabs->widget(Index);
QTableWidget *qDrvTab = new QTableWidget();
....
....
....
QVBoxLayout *vbLyt = new QVBoxLayout();
vbLyt->addWidget(qDrvTab);
qwgt->setLayout(vbLyt); 

When I add push buttons and tree widgets they all appear on the specified tab without any problem. Only the QTableWidget refuses to show.

Upvotes: 0

Views: 1287

Answers (1)

ScarCode
ScarCode

Reputation: 3094

A table with no rows and columns is a void.

So do

qDrvTab->setRowCount(no_of_rows);
qDrvTab->setColumnCount(no_of_cols);

before adding it to layout.

Now you can see your Tablewidget in layout.

Upvotes: 2

Related Questions