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. Creating new window from my mainwindow

Creating new window from my mainwindow

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 823 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.
  • S Offline
    S Offline
    sumsar1812
    wrote on last edited by
    #1

    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;

    cProfile.show();
    cProfile.raise();
    cProfile.activateWindow();
    }@

    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?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sumsar1812
        wrote on last edited by
        #3

        Ah i see thanks :)

        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