How to swap windows?
-
This is a very simple question that I can't quite get my head around...
If I click a button in the mainwindow it will hide mainwindow then make a NewWindow and show it. If I click on NewWindow it will hide NewWindow and then unhide mainwindow....
Question is, how do I get NewWindow (which is a child of mainwindow, I think?) to access mainwindow and tell it to do something?
@#include "mainwindow.h"
#include "ui_mainwindow.h"MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}MainWindow::~MainWindow()
{
delete ui;
}void MainWindow::on_Button_ToNew_clicked()
{
this->hide();
Instance1_NewWindow = new NewWindow(this);
Instance1_NewWindow->show();
}
@No idea where to start in the NewWindow
@#include "newwindow.h"
#include "ui_newwindow.h"#include "mainwindow.h"
NewWindow::NewWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::NewWindow)
{
ui->setupUi(this);
}NewWindow::~NewWindow()
{
delete ui;
}void NewWindow::on_Button_ToMain_clicked()
{}
@ -
Welcome to DevNet.
"Signals and slots":http://qt-project.org/doc/qt-5/signalsandslots.html will help you.
-
U can do it using qsharedmemory .
-
Why use something like QSharedMemory for that task ? Signals and Slots like qxoz suggested is the right way
-
Ohk. I misunderstood the question. i understood that there should be only a single instance. Probably i haven't read out it clearly. sorry for inconvenience .