[英]QT QTableWidget not appearing in QTabWidget
I have an application which uses multiple tabs. 我有一个使用多个标签的应用程序。 I used
QTabWidget
. 我用过
QTabWidget
。 On some tabs I needed to show tables, so I used QTableWidget
. 在某些标签上我需要显示表格,所以我使用了
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. 只有
QTableWidget
拒绝显示。
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. 现在,您可以在布局中看到Tablewidget。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.