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. Open a QDialog and then close the parent
Forum Updated to NodeBB v4.3 + New Features

Open a QDialog and then close the parent

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 318 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I have a QMainWindow that opens a bunch of QDialogs for user input that then triggers a specific action, e.g. copying data from a to b. These actions don't have to necessarily block the entire application, so I want to spawn a separate popup Dialog from the initial dialog. The behavior should be like this:

    1. Start Application
    2. Open Dialog
    3. Fill out form fields in the dialog and click 'Ok' to start the action
    4. New ProgressBar dialog pops up and initial dialog closes
    5. Action is running in the background, updating the progress bar in the new dialog

    Unfortunately, I can't manage to get a new QDialog popped up from the initial one without the initial one remaining open.

    MainWindow.cpp

    ...
    void MainWindow::copySlot()
    {
      CopyDialog copy(this);
      copy.exec();
    }
    ...
    

    CopyDialog.cpp

    ...
    void CopyDialog::progress()
    {
      ProgressBarWindow pb("Copy Data", 500);
      pb.exec();
    }
    

    I have played around with the modality and other things. When I'm using show() on the ProgressBarWindow it doesn't even pop up. What am I missing?

    Thanks!

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

      Hi,

      That’s because you allocate your dialogs on the stack so at the end of the function they get destroyed.

      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
      3

      • Login

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