Table = new QTableWidget(this); hbLayout = new QHBoxLayout(this); Table->setColumnCount(4); Table->setRowCount(5); //Table->setGeometry(20,20,500,300); hbLayout = new QHBoxLayout(this); hbLayout->addWidget(Table); this->setLayout(hbLayout);
#include <QApplication>#include <QWidget>#include <QBoxLayout>#include <QTableWidget>#include <QHeaderView>int main(int argc, char** argv) { QApplication app(argc, argv); QWidget wgt; QTableWidget* Table = new QTableWidget(&wgt); Table->horizontalHeader()->setResizeMode(QHeaderView::Stretch); Table->setColumnCount(4); Table->setRowCount(5); //Table->setGeometry(20,20,500,300); QHBoxLayout* hbLayout = new QHBoxLayout(&wgt); hbLayout->addWidget(Table); wgt.setLayout(hbLayout); wgt.show(); return app.exec();}
this->layout()->addWidget(Table);
MdiChildJournal::MdiChildJournal(QWidget *parent): QMainWindow(parent){ setAttribute(Qt::WA_DeleteOnClose); Table = new QTableWidget(this); Table->setColumnCount(4); Table->setRowCount(5); //qobject_cast<QMdiSubWindow*>(this)->widget; //НЕ ПРОКАТЫВАЕТ!!!}
class MdiChildJournal: public QMdiSubWindow,QMainWindow{}