Qt Code:
  1. void MainWindow::setGUI()
  2. {
  3. QWidget* frame = new QWidget;
  4. QToolButton *toolButton;
  5. _layout = new QVBoxLayout;
  6. frame->setLayout(_layout);
  7. tabWidget = new QTabWidget();
  8. tab = new QWidget();
  9. pushButton = new QPushButton(tab);
  10. tabWidget->addTab(tab, QString());
  11. _layout->addWidget(tabWidget);
  12. scrollArea = new QScrollArea;
  13. scrollArea->setWidget(frame);
  14. scrollArea->setWidgetResizable(true);
  15. setCentralWidget(scrollArea);
  16. }
To copy to clipboard, switch view to plain text mode 
This above works fine, i got scrollArea->tabWidget->tab->pushButton, but if I'd like to addWidget from other method/function to this layout i am not able to add new widget to "tab". Everything is under tabWidget which is part of scrollArea (centralWidget).
Qt Code:
  1. void MainWindow::addToGUI()
  2. {
  3. while(true)
  4. {
  5.  
  6. QGroupBox* newGB = new QGroupBox("group box");
  7. QFormLayout* form_layout = new QFormLayout;
  8.  
  9. layout->addRow("ID1", new QLabel(function()));
  10. layout->addRow("ID2", new QLabel(function()));
  11. layout->addRow("ID3", new QLabel(function()));
  12.  
  13. newGB->setLayout(layout);
  14. this->_layout->addWidget(newGB); // i want this in tabWidget->tab, i know that there is setCentralWIdget(scrollArea) and that is why i get this under tabWidget.
  15. }
  16. }
To copy to clipboard, switch view to plain text mode 

Here is what i mean -> 84465788e05d.jpg

How to solve this?