##// END OF EJS Templates
Implements method to register a widget in the dialog
Alexandre Leroux -
r464:236a0bfac326
parent child
Show More
@@ -20,6 +20,13 public:
20 explicit SqpSettingsDialog(QWidget *parent = 0);
20 explicit SqpSettingsDialog(QWidget *parent = 0);
21 virtual ~SqpSettingsDialog() noexcept;
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 private:
30 private:
24 Ui::SqpSettingsDialog *ui;
31 Ui::SqpSettingsDialog *ui;
25 };
32 };
@@ -15,3 +15,15 SqpSettingsDialog::~SqpSettingsDialog() noexcept
15 {
15 {
16 delete ui;
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