I have a QDialog
with a QComboBox
and a vertical layout in it. I also have many different QWidgets
that I want to add to vertical layout depending on a value selected in a QComboBox
. So, only one QWidget
at a time will be in a vertical layout.
What is the best way to achieve this in Qt?
Basically, I would like to have something like this:
ui->verticalLayout->addWidget(createMyWidget(myCombobox->currentText()));
where currentText
is the name of a class (there are a lot of different classes that are QWidgets
), and createMyWidget
returns pointer to newly created object. All that when signal currentTextChanged
emits.
I did this with a macro and a template function, but I would like to know if there is a better way in Qt.
Aucun commentaire:
Enregistrer un commentaire