Creating new window from my mainwindow

  • so I have made 2 windows, and from my mainwindow.cpp I am trying to create a new window when I click on a button

    The function I have connected with the button looks like this

    @void MainWindow::ProfileCreation()
    CreateProfile cProfile;;

    But when I try to click on the button, the window open for like 0,5-1 sec and then closes down again

    If i do this in my main.cpp file, where i create MainWindow, it works without problems and shows the window

    What should I do to make the window keep showing?

  • You create non-modal window using local variable.
    As soon as control leaves MainWindow::ProfileCreation() the cProfile is destroyed and closed.

    You need to declare cProfile as pointer in your MainWindow class then it will remain active until you close or destroy it.

  • Ah i see thanks :)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.