Results 1 to 2 of 2

Thread: using signals and slots to do action on mainwindow when child dialog is closed

  1. #1
    Join Date
    May 2011
    Posts
    1
    Qt products
    Qt4

    Default using signals and slots to do action on mainwindow when child dialog is closed

    Hi,

    I'm new in QT and i have some problems with signals and slots.
    I created and showed dialog on main window (when user click on graph, dialog is shown). Now, I want when close this dialog, to execute slot action defined on main window (draw text on mainwindow graph). Paert of mainwindow code:

    Dialog *d=new Dialog();
    connect(d, SIGNAL(d->finished(int)), this, SLOT(iscrtaj()));
    d->show();

    This is code for showing dialog after clicks on graph.

    In mainwindow, I defined slot called iscrtaj and implement it just to show message box (for test).
    This doesn't work. When dialog is closed, nothing is happening.

    I tried the same code, just in constructor of dialog, so slot is implemented in dialog:

    connect(this, SIGNAL(d->finished(int)), this, SLOT(iscrtaj()));

    and it works.

    So, problem is to link mainwindow and dialog.
    Can anybody tell me how?

    This is really urgent for me. I appreciate any kind of help.

    Thanks,

    Amer

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: using signals and slots to do action on mainwindow when child dialog is closed

    You can have a look at QDialog's accepted, finished or rejected signals.

    Or if this is not enough i think you could derive from QDialog and override closeEvent (you can call some function there or emit a signal there - i didn't try this but i guess it should work - maybe you can wait for more experienced opinions about this)

Similar Threads

  1. Replies: 4
    Last Post: 21st March 2011, 03:38
  2. Replies: 6
    Last Post: 17th September 2010, 08:15
  3. Replies: 0
    Last Post: 17th April 2010, 17:13
  4. MainWindow in front of child modeless dialog
    By jiveaxe in forum Qt Programming
    Replies: 4
    Last Post: 10th August 2007, 16:18
  5. Replies: 3
    Last Post: 23rd July 2006, 18: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.