Handling Main Window and Sub Windows



  • There is a strange problem with my application whenever i try to close main window,
    the main window simply get exit but sub windows remains open.
    And when last sub window get exit then main window also terminate.

    Main window is called from main class. While sub windows are called from other classes.

    Kindly help me how to tackle this problem...



  • Are you making the main window the parent widget for your sub-windows?



  • Can we see some code?



  • @class clientwindow : public QDialog , public Ui_Clientwindow
    {
    Q_OBJECT

    public:
    clientwindow(QWidget *parent = 0);@
    This is the main window(clientwindow) which is called in main class.

    @class Sessionwindow : public QDialog, public Ui_SessionWindow
    {
    Q_OBJECT

    public:
    explicit Sessionwindow(QDialog *parent = 0);@
    This is the sub window which is called in clientwindow class. Termination of this window close clientwindow.

    @class Transferwindow : public QDialog, public Ui_Transferwindow
    {
    Q_OBJECT

    public:
    explicit Transferwindow(Simplenetwork *simpleNetwork, QDialog *parent = 0);@
    This is also sub class which is called in clientwindow class. But termination of this window also close the clientwindow



  • This code doesn't help me a lot.

    From what I read above, it seems that your problem is that you don't create all the windows from the same place, and if you explicit @parent = this@ at each call, the windows would have different parents. If this is the case, you should make your program structure more hierarchical; for example, by creating one general class which creates (and it's parent of) all the others. That maybe comunicates with the others in order to know when it has to open a new window. Otherwise, you can also think of making the parent pointer a global variable which you can use at each call... but I don't know if this is a good practice.

    If my comprehension of your problem is not good, you should explain a little more as it is not very clear for the time being.

    Cheers,
    Sebastian



  • Thanks to all.
    My problem has solved. I was using @exit(0);@ in exit function of sub windows instead of @close();@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.