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. Connect closing dialog with a Qt List Widget

Connect closing dialog with a Qt List Widget

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

    HI. So my problem is the next: I have a main window with a button that opens a dialog box. Inside that dialog box I create a QStringList and all i want is to return this list from dialog to a QListWidget in main widget when I close the dialog. I suppose it can be solved with signals but i dont know how to use it.

    This is how I open the dialog from main widget:

    void home::on_AddPeopleBut_clicked()
    {
     addpeople* window=new addpeople(this);
     window->show();
    }
    

    In dialog i have the next function :

    QStringList addpeople::getList()
    
    {
        return selectedList;
       
    }
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      mpergand
      wrote on last edited by mpergand
      #2

      @Dy3zz said in Connect closing dialog with a Qt List Widget:

      addpeople* window=new addpeople(this);

      You create a dialog each time -> memory leak !

      for the signals, just look at the doc:

      Signals
      
      void accepted()
      void finished(int result)
      void rejected()
      

      and there are complete examples:

      A modal dialog:
       void EditorWindow::countWords()
       {
           WordCountDialog dialog(this);
           dialog.setWordCount(document().wordCount());
           dialog.exec();
       }
      A modeless dialog:
       void EditorWindow::find()
       {
           if (!findDialog) {
               findDialog = new FindDialog(this);
               connect(findDialog, SIGNAL(findNext()), this, SLOT(findNext()));
           }
      
           findDialog->show();
           findDialog->raise();
           findDialog->activateWindow();
       }
      
      D 1 Reply Last reply
      1
      • M mpergand

        @Dy3zz said in Connect closing dialog with a Qt List Widget:

        addpeople* window=new addpeople(this);

        You create a dialog each time -> memory leak !

        for the signals, just look at the doc:

        Signals
        
        void accepted()
        void finished(int result)
        void rejected()
        

        and there are complete examples:

        A modal dialog:
         void EditorWindow::countWords()
         {
             WordCountDialog dialog(this);
             dialog.setWordCount(document().wordCount());
             dialog.exec();
         }
        A modeless dialog:
         void EditorWindow::find()
         {
             if (!findDialog) {
                 findDialog = new FindDialog(this);
                 connect(findDialog, SIGNAL(findNext()), this, SLOT(findNext()));
             }
        
             findDialog->show();
             findDialog->raise();
             findDialog->activateWindow();
         }
        
        D Offline
        D Offline
        Dy3zz
        wrote on last edited by
        #3

        @mpergand It worked for me. I did this:

        void home::on_AddPeopleBut_clicked()
        {
             addpeople dialog(this);
             dialog.exec();
             QStringList a;
             a=dialog.getList();
             qDebug() << a[0];
        }
        

        I printed the first element to test . it worked perfectly. 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