Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to swap windows?

How to swap windows?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RayBradbury
    wrote on last edited by
    #1

    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()
    {

    }
    @

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qxoz
      wrote on last edited by
      #2

      Welcome to DevNet.

      "Signals and slots":http://qt-project.org/doc/qt-5/signalsandslots.html will help you.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ankursaxena
        wrote on last edited by
        #3

        U can do it using qsharedmemory .

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Why use something like QSharedMemory for that task ? Signals and Slots like qxoz suggested is the right way

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A Offline
            A Offline
            ankursaxena
            wrote on last edited by
            #5

            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 .

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved