Results 1 to 2 of 2

Thread: closing dialog window

  1. #1
    Join Date
    Jun 2010
    Posts
    18
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default closing dialog window

    I am making a program, which has got a main window. It will have two push buttons, when i push first button, it will open another dialog wondow say hashchain. and when i press second button second dialog window will open say communication. i requires that when i close child dialog window say hashchain, my mainwindow should not close. but i am facing a unique problem. when i open hashchain window & closes it, it also closes main window. whereas when i closes communication window, it closes without closing main window, but when i closes main window, communication window again pops up. please help. my code is

    mainwindow.h

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    #include "ui_mainwindow.h"
    #include "hashchain.h"
    #include "client.h"
    class mainwindow : public QDialog, public Ui::mainDialog
    {
    Q_OBJECT
    public:
    mainwindow(QWidget *parent = 0);
    private slots:
    void on_generateButton_clicked();
    void on_comnButton_clicked();
    private:
    hashchain *hash;
    client *cli;
    };
    #endif // MAINWINDOW_H

    mainwindow.cpp

    #include <QtGui>
    #include "mainwindow.h"
    #include "hashchain.h"
    #include "client.h"
    mainwindow::mainwindow(QWidget *parent) : QDialog(parent)
    {
    setupUi(this);
    connect( generatechainButton, SIGNAL( clicked() ), this, SLOT( on_generateButton_clicked() ) );
    connect( comnButton, SIGNAL( clicked() ), this, SLOT( on_comnButton_clicked() ) );
    hash = 0;
    cli = 0;
    }

    void mainwindow:n_generateButton_clicked()
    {
    if (!hash) {
    hash = new hashchain(this);

    }
    hash->show();
    hash->activateWindow();
    }

    void mainwindow:n_comnButton_clicked()
    {
    if (!cli) {
    cli = new client(this);
    }
    cli->show();
    cli->activateWindow();
    }

  2. #2
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: closing dialog window

    I have a main window application with many dialogs and no problems, but my code looks like this:

    Qt Code:
    1. class MainWindow : public QMainWindow
    2. {
    3. Q_OBJECT
    4. // and more
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. MainWindow::MainWindow(QWidget* parent)
    2. : QMainWindow(parent), ui(new Ui::MainWindow)
    3. {
    4. // and more
    To copy to clipboard, switch view to plain text mode 

    Could be your declarations are giving you the trouble.

Similar Threads

  1. closing child dialog closes parent dialog
    By sparticus_37 in forum Newbie
    Replies: 2
    Last Post: 28th May 2010, 19:46
  2. passing data when closing a dialog
    By jimiq in forum Newbie
    Replies: 4
    Last Post: 4th November 2009, 16:48
  3. closing a dialog
    By chrisb123 in forum Newbie
    Replies: 40
    Last Post: 27th October 2009, 12:37
  4. Closing a dialog using a button
    By srohit24 in forum Qt Programming
    Replies: 5
    Last Post: 21st July 2009, 05:57
  5. Dialog is not closing
    By manmohan in forum Newbie
    Replies: 5
    Last Post: 1st December 2008, 17:04

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.