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. Whether Dialog window's object's memory is leaking or not ?
Qt 6.11 is out! See what's new in the release blog

Whether Dialog window's object's memory is leaking or not ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 251 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.
  • I Offline
    I Offline
    IiaryPrashant56_
    wrote on last edited by
    #1
    void MainWindow::on_pushButton_clicked()
    {
        toDoList = new Dialog(this);
        toDoList->exec();
        int code = toDoList->result();
    
        // print dialog code returned
        switch(code){
        case 0:
            qDebug()<< "Rejected Dialog code is returned "<<Qt::endl;
            break;
        case 1:
            qDebug()<< "Accepted Dialog code is returned "<< Qt::endl;
            break;
        default:
            qDebug()<< "Nothing is return form Dialog Window"<< Qt::endl;
    
        }
    }
    

    I just want to know if Somewhere ; memory is leaking or not of dialog window object because i am not deleting it before function return because. Thanks for you valuable reply in advance.

    Christian EhrlicherC SGaistS 2 Replies Last reply
    0
    • I IiaryPrashant56_
      void MainWindow::on_pushButton_clicked()
      {
          toDoList = new Dialog(this);
          toDoList->exec();
          int code = toDoList->result();
      
          // print dialog code returned
          switch(code){
          case 0:
              qDebug()<< "Rejected Dialog code is returned "<<Qt::endl;
              break;
          case 1:
              qDebug()<< "Accepted Dialog code is returned "<< Qt::endl;
              break;
          default:
              qDebug()<< "Nothing is return form Dialog Window"<< Qt::endl;
      
          }
      }
      

      I just want to know if Somewhere ; memory is leaking or not of dialog window object because i am not deleting it before function return because. Thanks for you valuable reply in advance.

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by Christian Ehrlicher
      #2

      It does not leak, it's cleaned up when MainWindow gets destroyed as described in the documentation.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • I IiaryPrashant56_
        void MainWindow::on_pushButton_clicked()
        {
            toDoList = new Dialog(this);
            toDoList->exec();
            int code = toDoList->result();
        
            // print dialog code returned
            switch(code){
            case 0:
                qDebug()<< "Rejected Dialog code is returned "<<Qt::endl;
                break;
            case 1:
                qDebug()<< "Accepted Dialog code is returned "<< Qt::endl;
                break;
            default:
                qDebug()<< "Nothing is return form Dialog Window"<< Qt::endl;
        
            }
        }
        

        I just want to know if Somewhere ; memory is leaking or not of dialog window object because i am not deleting it before function return because. Thanks for you valuable reply in advance.

        SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

        Your not deleting it at all so yes the memory use will increase until MainWindow is deleted.

        Create your dialog on the stack, the way you use it does not justify to use the heap.

        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
        1

        • Login

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