I want to display in button click a stackwidget with some information.
However, having trouble to do this. I have 2 files : mainwindow.cpp and ppualert.cpp and i want to open the file ppualert while the user click the button in mainwindow. (something like div in html)
my main problem : the stackwidget is shown allways and his buttons does not response.
what am i do wrong? BTW i can't open it in another different window cause i am workin with qt linux embedded and eglfs plugin, it's write the widgets straight to frame buffer and limited to one window.
here is the code:
MainWindow.cpp:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "ppualert.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ppu = new ppuAlert(this);
connect(ppu,&ppuAlert::ppuDialogClosed,this,&MainWindow::onPPUDialogClosed);
ui->swPPU->addWidget(new ppuAlert);
ui->swPPU->hide();
}
void MainWindow::on_btnShowPPU_clicked()
{
ui->swPPU->setCurrentIndex(0);
ui->swPPU->show();
}
void MainWindow::onPPUDialogClosed()
{
ui->swPPU->hide();
}
ppualert.cpp:
#include "ppualert.h"
#include "ui_ppualert.h"
ppuAlert::ppuAlert(QWidget *parent) :
QWidget(parent),
ui(new Ui::ppuAlert)
{
ui->setupUi(this);
}
ppuAlert::~ppuAlert()
{
delete ui;
}
void ppuAlert::on_pushButton_5_clicked()
{
emit ppuDialogClosed();
}
MainWindow.h:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "ppualert.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
ppuAlert *ppu;
public slots:
void on_btnShowPPU_clicked();
void onPPUDialogClosed();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
ppualert.h:
#ifndef PPUALERT_H
#define PPUALERT_H
#include <QWidget>
namespace Ui {
class ppuAlert;
}
class ppuAlert : public QWidget
{
Q_OBJECT
public:
explicit ppuAlert(QWidget *parent = 0);
~ppuAlert();
private slots:
void on_pushButton_5_clicked();
private:
Ui::ppuAlert *ui;
signals:
void ppuDialogClosed();
};
#endif // PPUALERT_H