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. Destroy dialogs

Destroy dialogs

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 2.5k Views
  • 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.
  • K Offline
    K Offline
    knetcozd
    wrote on last edited by
    #1

    I have a login dialog that shows up when my App loads , Thereafter i have a Main Window ,Once the user is validated i want to destroy the login dialog and show only the Main Window. My problem is i cant seem to be able to destroy the dialog - i have tried using LoginDialog::destroy() and LoginDialog::close() but neither works - all that happens is that the main windows shows up and the Login dialog still remains in behind the main window.

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      There is a number of approaches:

      If you know beforehand that you're going to destroy it when it is closed:
      @
      Dialog *d = new Dialog(this);
      d->setAttribute(WA_DeleteOnClose);
      @

      If you are going to destroy it when finished:
      @
      Dialog *d = new Dialog(this);
      connect(d, SIGNAL(accepted()), d, SLOT(deleteLater()));
      @

      If you have something to validate in a slot:
      @
      if (stuffWasOk)
      d->deleteLater();
      @

      Of course these approaches all have their uses and drawbacks. By the way, deleteLater() is the correct function to use to get rid of the thing at all times. It tells the event loop to delete it. If you were to use delete directly, the event loop might try to deliver events to an object that no longer exists.

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • G Offline
        G Offline
        giesbert
        wrote on last edited by
        #3

        Hi knetcozd,

        can you show some simple example code where it does not work?

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        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