1 Attachment(s)
addWidget other place than setCentralWidget()
Code:
void MainWindow::setGUI()
{
frame->setLayout(_layout);
_layout->addWidget(tabWidget);
scrollArea->setWidget(frame);
scrollArea->setWidgetResizable(true);
setCentralWidget(scrollArea);
}
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).
Code:
void MainWindow::addToGUI()
{
while(true)
{
QFormLayout* form_layout = new QFormLayout;
layout
->addRow
("ID1",
new QLabel(function
()));
layout
->addRow
("ID2",
new QLabel(function
()));
layout
->addRow
("ID3",
new QLabel(function
()));
newGB->setLayout(layout);
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.
}
}
Here is what i mean -> Attachment 7114
How to solve this?
Re: addWidget other place than setCentralWidget()
Just add needed widgets to QTabWidget's tab (better place layout there), not to main window's layout.
Re: addWidget other place than setCentralWidget()
Quote:
Originally Posted by
Oleg
Just add needed widgets to QTabWidget's tab (better place layout there), not to main window's layout.
I'm QT noob, and i'm not sure what u mean. since a few yeras i only use php oop.
I removed this line "this->_layout->addWidget(newGB);" from addToGUI(), and wrote "_layout->addWidget(newGB);" in setGUI() but I got app crash, that exe is not responding (headers are correct).
Re: addWidget other place than setCentralWidget()
1. BTW, create all widgets in visual editor, it's much easier.
2. Add layout to your tab
3. Add QPushButton and QGroupBox to that layout
Code:
tab->layout()->addWidget(newGB);