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. Multiple Windows Desktop application
Forum Updated to NodeBB v4.3 + New Features

Multiple Windows Desktop application

Scheduled Pinned Locked Moved General and Desktop
13 Posts 5 Posters 23.1k 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.
  • C Offline
    C Offline
    Code_ReaQtor
    wrote on last edited by
    #4

    try "IPC":http://doc.qt.digia.com/main-snapshot/ipc.html

    Please visit my open-source projects at https://github.com/Code-ReaQtor.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #5

      IPC is only necessary if the windows are controlled by different processes. I doubt that is what rufy23 wants to do.

      rufy23: Of course you can use signals and slots between different UIs. You just can not set them in the designer, but are free to add them from your code later.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Code_ReaQtor
        wrote on last edited by
        #6

        bq. hides the current window and shows another window

        Sorry, did I mistakenly interpreted this as independent windows? My bad.

        This "link":http://doc.qt.digia.com/qt/tools-customtypesending.html might be a little different but the theory is the same, I think.

        Please visit my open-source projects at https://github.com/Code-ReaQtor.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          rufy23
          wrote on last edited by
          #7

          Thank you, I understand what you say. Now I ask another help: is there an easier and faster way to do this? I have to do an application with a lot of windows linked together and I think it is not so easy to do without the qt designer, also becouse I always used it to do everything.

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rufy23
            wrote on last edited by
            #8

            For example is there a way to melt a qmainwindow with a qstackedwidget in the designer? I think it could resolve my problem, isn't it?

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #9

              No, it is not. Qt Designer is a great tool for designing widgets, but it is not a complete visual programming environment. You still need to write code. If you try to force everything into one single designer file, you're going to end up with a single huge class. That is not very maintainable or reusable.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                rufy23
                wrote on last edited by
                #10

                Ok, but I can't understand just one thing. If I create a lot of classes, one for each window for example, how can I connect them in this way? I have some difficulties to create signals which are referred to different objects.
                For Example I create a class for the first window and another class for the second. I have for each of the both three files (first window has: ui_firstwindow.h firstwindow.h firstwindow.cpp and the same thing for the second window). In first window there is a pushbutton called next which hides first window and shows second window. In second window there is a pushbutton called previous which hides second window and shows first window. For the next button where do I have to put the connect?I have this problem becouse I can't understand how to connect different objects.

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  ChrisW67
                  wrote on last edited by
                  #11

                  Define an exposed signal in your window class:
                  @
                  class Window1: public QWidget
                  {
                  ...
                  signals:
                  void showOtherWindow();
                  };
                  @

                  Connect the push button to your own hide() slot and also emit the signal:
                  @
                  Window1::Window1(QWidget *p = 0):
                  QWidget(p), ui(new Ui::Window1)
                  {
                  ui->setupUi(this);
                  connect(ui->pushButton, SIGNAL(clicked()), SLOT(hide()));
                  connect(ui->pushButton, SIGNAL(clicked()), SIGNAL(showOtherWindow()));
                  }
                  @
                  You can connect a signal to another signal and arrival of the first will trigger emit on the second. Window2 looks the same. In your main:
                  @
                  int main(int argc, char **argv)
                  {
                  QApplication app(argc, argv);

                  Window1 w1;
                  Window2 w2;
                  
                  QObject::connect(&w1, SIGNAL(showOtherWindow()), &w2, SLOT(show()));
                  QObject::connect(&w2, SIGNAL(showOtherWindow()), &w1, SLOT(show()));
                  w1.show();  // only show one of them to start
                  
                  return app.exec();
                  

                  }
                  @

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    rufy23
                    wrote on last edited by
                    #12

                    Thank you very much, it is very usefull. Just another little thing, not very important. If I build the window with the designer, can I copy the code generated and use it in my application, or is there something more or something less?

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      andre
                      wrote on last edited by
                      #13

                      Don't copy the generated code. Include it instead and use it that way.

                      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