Close QDialog: Not calling the on_clicked() method
-
I'm developing a Qt C++ GUI
shared library.void Plugin::showUI() const { Dialog a; a.setModal(true); a.exec(); }My UI have a buttom called "Save".
void Dialog::on_save_btn_clicked() { qDebug() << "SAVE"; }It compiles without any warnings or errors. All ok!
The plugin UI appears ok too.My problem: When I click on the save button, the method above is not called! Why?
How can I fix it?
-
@SGaist sorry...here is my
Dialogclass.#ifndef DIALOG_H #define DIALOG_H #include <QDialog> namespace Ui { class Dialog; } class Dialog : public QDialog { Q_OBJECT public: explicit Dialog(QWidget *parent = nullptr); ~Dialog(); void on_save_btn_clicked(); private: Ui::Dialog *ui; }; #endif // DIALOG_H#include "dialog.h" #include "ui_dialog.h" #include <QDebug> Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) { ui->setupUi(this); } Dialog::~Dialog() { delete ui; } void Dialog::on_save_btn_clicked() { qDebug() << "SAVE"; }I just added this "save_btn_clicked" from the Qt Designer using: right-click -> Go To Slot -> Clicked()
@fem_dev said in Close QDialog: Not calling the on_clicked() method:
I just added this "save_btn_clicked" from the Qt Designer using: right-click -> Go To Slot -> Clicked()
It can't be...The "save_btn_clicked" function is not even a slot!
That's why it doesn't work...
If you create it using designer, it should be added as a slot like this:private slots: void on_save_btn_clicked();Unless you've deleted that "private slots:" line.
-
Hi,
Without the code form Dialog, it's hard to guess...
-
@SGaist sorry...here is my
Dialogclass.#ifndef DIALOG_H #define DIALOG_H #include <QDialog> namespace Ui { class Dialog; } class Dialog : public QDialog { Q_OBJECT public: explicit Dialog(QWidget *parent = nullptr); ~Dialog(); void on_save_btn_clicked(); private: Ui::Dialog *ui; }; #endif // DIALOG_H#include "dialog.h" #include "ui_dialog.h" #include <QDebug> Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) { ui->setupUi(this); } Dialog::~Dialog() { delete ui; } void Dialog::on_save_btn_clicked() { qDebug() << "SAVE"; }I just added this "save_btn_clicked" from the Qt Designer using: right-click -> Go To Slot -> Clicked()
-
@SGaist sorry...here is my
Dialogclass.#ifndef DIALOG_H #define DIALOG_H #include <QDialog> namespace Ui { class Dialog; } class Dialog : public QDialog { Q_OBJECT public: explicit Dialog(QWidget *parent = nullptr); ~Dialog(); void on_save_btn_clicked(); private: Ui::Dialog *ui; }; #endif // DIALOG_H#include "dialog.h" #include "ui_dialog.h" #include <QDebug> Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) { ui->setupUi(this); } Dialog::~Dialog() { delete ui; } void Dialog::on_save_btn_clicked() { qDebug() << "SAVE"; }I just added this "save_btn_clicked" from the Qt Designer using: right-click -> Go To Slot -> Clicked()
@fem_dev said in Close QDialog: Not calling the on_clicked() method:
I just added this "save_btn_clicked" from the Qt Designer using: right-click -> Go To Slot -> Clicked()
It can't be...The "save_btn_clicked" function is not even a slot!
That's why it doesn't work...
If you create it using designer, it should be added as a slot like this:private slots: void on_save_btn_clicked();Unless you've deleted that "private slots:" line.
-
@fem_dev said in Close QDialog: Not calling the on_clicked() method:
I just added this "save_btn_clicked" from the Qt Designer using: right-click -> Go To Slot -> Clicked()
It can't be...The "save_btn_clicked" function is not even a slot!
That's why it doesn't work...
If you create it using designer, it should be added as a slot like this:private slots: void on_save_btn_clicked();Unless you've deleted that "private slots:" line.