Greetings to all of you!
I am facing a problem of connecting a parent window with a children one. I have successfully implemented each window as well as their respectives widgets, but the slots of the children window does not work.
Here is my code:
#ifndef DEF_ESSAIE
#define DEF_ESSAIE
#include <QtGui>
{
Q_OBJECT
public:
Essaie();
~Essaie();
private slots:
void ouvrirFenetre1();
private:
};
#endif // ESSAIE_H
#ifndef DEF_ESSAIE
#define DEF_ESSAIE
#include <QtGui>
class Essaie: public QMainWindow
{
Q_OBJECT
public:
Essaie();
~Essaie();
private slots:
void ouvrirFenetre1();
private:
QMainWindow *m_fenetrePrincipale;
QPushButton *m_butonFenetre1;
};
#endif // ESSAIE_H
To copy to clipboard, switch view to plain text mode
#ifndef DEF_FENETRE1
#define DEF_FENETRE1
#include<QtGui>
{
Q_OBJECT
public:
~Fenetre1();
private slots:
void displayList();
private:
};
#endif // FENETRE1_H
#ifndef DEF_FENETRE1
#define DEF_FENETRE1
#include<QtGui>
class Fenetre1: public QMainWindow
{
Q_OBJECT
public:
Fenetre1(QWidget *parent);
~Fenetre1();
private slots:
void displayList();
private:
QWidget *m_fenetre1;
QPushButton *m_butonFermer;
};
#endif // FENETRE1_H
To copy to clipboard, switch view to plain text mode
#include "Essaie.h"
#include "Fenetre1.h"
Essaie::Essaie()
{
m_fenetrePrincipale->setFixedSize(300, 200);
m_butonFenetre1->move(75, 100);
connect(m_butonFenetre1, SIGNAL(clicked()), this, SLOT(ouvrirFenetre1()));
}
void Essaie::ouvrirFenetre1()
{
Fenetre1 *fene = new Fenetre1(this);
fene->show();
}
Essaie::~Essaie()
{}
#include "Essaie.h"
#include "Fenetre1.h"
Essaie::Essaie()
{
m_fenetrePrincipale = new QMainWindow;
m_fenetrePrincipale->setFixedSize(300, 200);
m_butonFenetre1 = new QPushButton("Ouvrir", this);
m_butonFenetre1->move(75, 100);
connect(m_butonFenetre1, SIGNAL(clicked()), this, SLOT(ouvrirFenetre1()));
}
void Essaie::ouvrirFenetre1()
{
Fenetre1 *fene = new Fenetre1(this);
fene->show();
}
Essaie::~Essaie()
{}
To copy to clipboard, switch view to plain text mode
#include "Fenetre1.h"
{
this->setFixedSize(200, 150);
this->setWindowTitle("Fenetre1");
connect(m_butonFermer, SIGNAL(clicked()), this, SLOT(close()));
connect(m_butonDisplay, SIGNAL(clicked()), this, SLOT(displayList()));
}
Fenetre1::~Fenetre1()
{}
#include "Fenetre1.h"
Fenetre1::Fenetre1(QWidget *parent = 0): QMainWindow(parent)
{
this->setFixedSize(200, 150);
this->setWindowTitle("Fenetre1");
m_butonFermer = new QPushButton("Fermer", this);
connect(m_butonFermer, SIGNAL(clicked()), this, SLOT(close()));
connect(m_butonDisplay, SIGNAL(clicked()), this, SLOT(displayList()));
}
Fenetre1::~Fenetre1()
{}
To copy to clipboard, switch view to plain text mode
On the children window, the closing slot is working properly, but not that of display.
I would be greatfull to you if you could help me overcoming this problem.
Many thanks in advance!
Bookmarks