##// END OF EJS Templates
Implements method to register a widget in the dialog
Alexandre Leroux -
r428:236a0bfac326
parent child
Show More
@@ -1,27 +1,34
1 1 #ifndef SCIQLOP_SQPSETTINGSDIALOG_H
2 2 #define SCIQLOP_SQPSETTINGSDIALOG_H
3 3
4 4 #include "Settings/ISqpSettingsBindable.h"
5 5
6 6 #include <QDialog>
7 7
8 8 namespace Ui {
9 9 class SqpSettingsDialog;
10 10 } // Ui
11 11
12 12 /**
13 13 * @brief The SqpSettingsDialog class represents the dialog in which the parameters of SciQlop are
14 14 * set
15 15 */
16 16 class SqpSettingsDialog : public QDialog {
17 17 Q_OBJECT
18 18
19 19 public:
20 20 explicit SqpSettingsDialog(QWidget *parent = 0);
21 21 virtual ~SqpSettingsDialog() noexcept;
22 22
23 /**
24 * Registers a widget into the dialog
25 * @param name the name under which the widget will appear in the dialog
26 * @param widget the widget to register
27 */
28 void registerWidget(const QString &name, QWidget *widget) noexcept;
29
23 30 private:
24 31 Ui::SqpSettingsDialog *ui;
25 32 };
26 33
27 34 #endif // SCIQLOP_SQPSETTINGSDIALOG_H
@@ -1,17 +1,29
1 1 #include "Settings/SqpSettingsDialog.h"
2 2 #include "ui_SqpSettingsDialog.h"
3 3
4 4 SqpSettingsDialog::SqpSettingsDialog(QWidget *parent)
5 5 : QDialog{parent}, ui{new Ui::SqpSettingsDialog}
6 6 {
7 7 ui->setupUi(this);
8 8
9 9 // Connection to change the current page to the selection of an entry in the list
10 10 connect(ui->listWidget, &QListWidget::currentRowChanged, ui->stackedWidget,
11 11 &QStackedWidget::setCurrentIndex);
12 12 }
13 13
14 14 SqpSettingsDialog::~SqpSettingsDialog() noexcept
15 15 {
16 16 delete ui;
17 17 }
18 void SqpSettingsDialog::registerWidget(const QString &name, QWidget *widget) noexcept
19 {
20 auto newItem = new QListWidgetItem{ui->listWidget};
21 newItem->setText(name);
22
23 ui->stackedWidget->addWidget(widget);
24
25 // Selects widget if it's the first in the dialog
26 if (ui->listWidget->count() == 1) {
27 ui->listWidget->setCurrentItem(newItem);
28 }
29 }
General Comments 0
You need to be logged in to leave comments. Login now