i created a form mainwindow class in QT creator, and an action element in a menuBar, and i want that when we click on it, it show an other form called DataWindow
Here is my mainwindow.h
private slots:
void on_actionNouvellesDonnees_clicked();
Here is my mainwindow.ccp
void MainWindow::on_actionNouvellesDonnees_clicked() {
DataWindow w;
w.show();
}
But when i debug and i click on my action menu, the DataWindow is not showed… and the debug tool said me :
QMetaObject::connectSlotsByName: No matching signal for on_actionNouvellesDonnees_clicked()
Thanks for any help !
Complete mainwindow.ccp :
#include <QtGui/QApplication>
#include <QApplication>
#include <QMessageBox>
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "datawindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
//QObject::connect(ui->actionNouvellesDonnees, SIGNAL(triggered()), this, SLOT(on_actionNouvellesDonnees_clicked()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_actionNouvellesDonnees_triggered() {
DataWindow w;
w.show();
}
Complete mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void on_actionNouvellesDonnees_triggered();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
Which signal do you connect on_actionNouvellesDonnees_clicked? If it is an action(like in main menu) correct signal isn’t “clicked()”, you can use “triggered()”.
Try this