Results 1 to 3 of 3

Thread: Passing data from a QDialog to a QMainWindow using signal/slots

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Passing data from a QDialog to a QMainWindow using signal/slots

    You create a new dialog in main window's constructor and never exec it, it is useless.
    Remove it from the constructor and connect to instances created in on_Open_clicked() slot:
    Qt Code:
    1. void MainWindow::on_Open_clicked()
    2. {
    3. Dialog *dialog = new Dialog (this); // remember to set parent !
    4. dialog->setModal(true);
    5. connect(dialog, SIGNAL(validate(QString)), this, SLOT(validate(QString)));
    6. dialog->exec();
    7.  
    8. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Passing data from a QDialog to a QMainWindow using signal/slots

    QDialog::exec() always sets modality to true, so no need to do that explicitly

    Cheers,
    _

Similar Threads

  1. How to pass a member data from QMainWindow to QDialog
    By pollausen85 in forum Qt Programming
    Replies: 3
    Last Post: 11th October 2013, 10:40
  2. Passing a object between QDialog and QMainWindow
    By m_bishop in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2013, 14:53
  3. Replies: 3
    Last Post: 22nd September 2011, 05:47
  4. Passing data via signal/slot
    By gib in forum Qt Programming
    Replies: 4
    Last Post: 1st November 2010, 05:49
  5. QDialog and QMainWindow Data Transfer
    By Ahmad in forum Qt Programming
    Replies: 12
    Last Post: 6th May 2007, 07:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.