QMainWindow
-
I have created a main window with a qvboxlayout where I have placed a combobox, a tree widget and the button ok. When I click the button ok, I create a new qvboxlayout with some widgets. The new qvboxlayout has the button return. How can I return to the first window with the choices of the user?
Do I have to create a new MainWindow or is there a function that does the whole work?The code is :
@
QXSRExample::QXSRExample(QWidget parent) : QMainWindow(parent) {
setupUI();
}
QXSRExample::~QXSRExample() {
}
void QXSRExample::setupUI() {
QFrame frame = new QFrame(this);_layout = new QVBoxLayout; frame->setLayout(_layout); parseXML(); QScrollArea* scrollArea = new QScrollArea; scrollArea->setWidget(frame); scrollArea->setWidgetResizable(true); setCentralWidget(scrollArea);
}
………
void QXSRExample::details(QTreeWidgetItem* item,int column){
itemName= item->data(column, Qt::DisplayRole).toString(); QFrame* frame2 = new QFrame(this); _layout = new QVBoxLayout; frame2->setLayout(_layout); QScrollArea* scrollArea = new QScrollArea; scrollArea->setWidget(frame2); scrollArea->setWidgetResizable(true); setCentralWidget(scrollArea); while(!persons3.isEmpty()) { QMap<QString,QString> person = persons3.takeFirst(); if ((person["surname"]==itemName) or (person["name"]==itemName)){ QGroupBox* personGB = new QGroupBox("Patient"); QFormLayout* layout = new QFormLayout; layout->addRow("ID", new QLineEdit(person["id"])); …………. personGB->setLayout(layout); this->_layout->addWidget(personGB); } } QPushButton* ok = new QPushButton("Return"); _layout->addWidget(ok, 1, Qt::AlignCenter); connect(ok, SIGNAL(clicked()),this, SLOT(cancel()));
}
@EDIT: please only use one @-tag in the beginning of the code, and one in the end, Gerolf