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. Handling Main Window and Sub Windows
Forum Updated to NodeBB v4.3 + New Features

Handling Main Window and Sub Windows

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 3.7k Views 1 Watching
  • 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.
  • W Offline
    W Offline
    wasim3s
    wrote on last edited by
    #1

    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...

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris H
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Seba84
        wrote on last edited by
        #3

        Can we see some code?

        1 Reply Last reply
        0
        • W Offline
          W Offline
          wasim3s
          wrote on last edited by
          #4

          @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

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Seba84
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • W Offline
              W Offline
              wasim3s
              wrote on last edited by
              #6

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

              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