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. Two mainwindows in the same instace

Two mainwindows in the same instace

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 357 Views 2 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
    Chicowolf
    wrote on last edited by
    #1

    Hello :)
    I'm developing a serial monitor for a microcontroller for an academic project. I need to create a program that has 2 MainWindows. In particular when i press a button in the first window, this one closes and fire up the second one. Viceversa when i press a button on the second windows, this closes and fire up the first one.

    I tryed to do something like this using the exit codes in the main.cpp file, but i can't manage to achieve what i need.
    Can you help me?

    JonBJ 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Out of curiosity, why do you need them to be both MainWindows ?

      Depending on that, you could use QStackedWidget and switch between the two widgets.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • B Offline
        B Offline
        Bonnie
        wrote on last edited by
        #3

        I think there's nothing to do with exit code...

        1 Reply Last reply
        2
        • C Chicowolf

          Hello :)
          I'm developing a serial monitor for a microcontroller for an academic project. I need to create a program that has 2 MainWindows. In particular when i press a button in the first window, this one closes and fire up the second one. Viceversa when i press a button on the second windows, this closes and fire up the first one.

          I tryed to do something like this using the exit codes in the main.cpp file, but i can't manage to achieve what i need.
          Can you help me?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @Chicowolf
          The easiest way of showing different windows is via QStackedWidget, either on its own or inside a QMainWindow.

          If you really want to have separate windows, use show() & hide(), firing them in the button slots.

          When you start speaking about "exit codes" you are talking about separate programs, which is quite a different thing. You do not want separate programs, do you?

          1 Reply Last reply
          1
          • C Offline
            C Offline
            Chicowolf
            wrote on last edited by
            #5

            Thanks for the replies.
            Yes i need separate programs. The first windows does some stuff to the micro via serial port, and the second window does other stuff over serial port too.

            I tryed to use hide() and show(), but when the first windows shows the second window, doesn't become "disabled" and permits the user to interact with the first window(for example, the user can press some buttons), even if the second window is showed, which can lead to bad beheaving of the micro if the user send some serial codes of the first window while the second windows is opened. That's because the two windows represents two different logic states of the micro.

            So i don't know if QStackedWidget is a viable option for this strange problem.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              But why do you need separate applications to work with the same microcontroller using the same serial port ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved