Hi everyone.
I need a little help.
I am developing an application using MdiArea and can not close another
form through its close button (PushButton).
Can someone show me where I am going wrong, follows code below.
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "formwidget.h" [COLOR="#FF0000"]-----------> Include of SubWindow[/COLOR]
namespace Ui {
class MainWindow;
}
{
Q_OBJECT
public:
explicit MainWindow
(QWidget *parent
= 0);
~MainWindow();
private slots:
void on_actionClients_triggered();
private:
Ui::MainWindow *ui;
};
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "formwidget.h" [COLOR="#FF0000"]-----------> Include of SubWindow[/COLOR]
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void on_actionClients_triggered();
private:
Ui::MainWindow *ui;
};
To copy to clipboard, switch view to plain text mode
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
setCentralWidget(ui->mdiArea); [COLOR="#FF0000"]---------> Centering MdiArea[/COLOR]
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_actionClients_triggered()
{
FormWidget *frmClients = new FormWidget;
ui->mdiArea->addSubWindow(frmClients);
frmClients->show(); [COLOR="#FF0000"]-----------------------------> Instantiating the subwindow[/COLOR]
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setCentralWidget(ui->mdiArea); [COLOR="#FF0000"]---------> Centering MdiArea[/COLOR]
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_actionClients_triggered()
{
FormWidget *frmClients = new FormWidget;
ui->mdiArea->addSubWindow(frmClients);
frmClients->show(); [COLOR="#FF0000"]-----------------------------> Instantiating the subwindow[/COLOR]
}
To copy to clipboard, switch view to plain text mode
#include "formwidget.h"
#include "ui_formwidget.h"
FormWidget
::FormWidget(QWidget *parent
) : ui(new Ui::FormWidget)
{
ui->setupUi(this);
}
FormWidget::~FormWidget()
{
delete ui;
}
void FormWidget::on_pushButton_clicked()
{
close(); --------> [COLOR="#FF0000"]Does not work, the widget disappears (LineEdit, Label, Pushbutton) and the form does not close.[/COLOR]
}
#include "formwidget.h"
#include "ui_formwidget.h"
FormWidget::FormWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::FormWidget)
{
ui->setupUi(this);
}
FormWidget::~FormWidget()
{
delete ui;
}
void FormWidget::on_pushButton_clicked()
{
close(); --------> [COLOR="#FF0000"]Does not work, the widget disappears (LineEdit, Label, Pushbutton) and the form does not close.[/COLOR]
}
To copy to clipboard, switch view to plain text mode
I thank the help.
João Marcos .
Bookmarks