Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt Not Allowing Opening of New Window



  • This little block of code here used to work

    Header:
    @
    private:
    Ui::MainWindow *ui;
    MainInterface *mainInterfaceOpen;
    };
    @

    CPP:
    @
    void MainWindow::on_startNewSimulationButton_clicked()
    {
    mainInterfaceOpen = new MainInterface(this);
    this->hide();
    mainInterfaceOpen->show();
    this->close();
    }
    @

    But now, after I tried the similar thing in my MainInterface class, NEITHER of them work.

    It spits back to me about my header,
    @
    error: C2143: syntax error : missing ';' before '*'
    @
    @
    private:
    Ui::MainWindow *ui;
    MainInterface *mainInterfaceOpen;
    };
    @

    So it's telling me I'm starting a new window wrong, but everywhere I look this is EXACTLY how it is supposed to be done. I have maininterface.h included... I've tried cleaning, running qmake, and rebuilding....

    What is going on?


  • Moderators

    Hi,
    In the on_startNewSimulationButton_clicked() your are closing your MainWindow using " this->close();" after you show the "MainInterface" window. It actually kills the MainWindow and therefore "MainInterface" also.


Log in to reply