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. Open Window from Sibling Window

Open Window from Sibling Window

Scheduled Pinned Locked Moved General and Desktop
qt creatorwindowshow
11 Posts 2 Posters 3.3k Views
  • 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.
  • artwawA Offline
    artwawA Offline
    artwaw
    wrote on last edited by
    #2

    Hi,
    assuming SettingsWindow is QDialog descentant I would connect button's clicked signal with method that does something like:

    SettingsWindow->exec();
    

    Please read QDialog class documentation, there are also hints how to determine which button was used to close the dialog (through signal/slot mechanism).

    Kind Regards,
    Artur

    For more information please re-read.

    Kind Regards,
    Artur

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Cosford
      wrote on last edited by Cosford
      #3

      Hi, thanks for your reply.

      SettingsWindow is indeed derived from QDialog.

      I assume I should make the slot/signal connection from MainWindow (where said button is a child of), although I'm unsure how to do this as SettingsWindow is an object held by the SettingsManager object, which along with MainWindow are both objects held by the ApplicationManager. Therefore, I don't believe that MainWindow can see the SettingsWindow, nor the SettingsManager object.

      I hope I've made myself clear enough?

      Regards,
      Cosford.

      artwawA 2 Replies Last reply
      0
      • C Cosford

        Hi, thanks for your reply.

        SettingsWindow is indeed derived from QDialog.

        I assume I should make the slot/signal connection from MainWindow (where said button is a child of), although I'm unsure how to do this as SettingsWindow is an object held by the SettingsManager object, which along with MainWindow are both objects held by the ApplicationManager. Therefore, I don't believe that MainWindow can see the SettingsWindow, nor the SettingsManager object.

        I hope I've made myself clear enough?

        Regards,
        Cosford.

        artwawA Offline
        artwawA Offline
        artwaw
        wrote on last edited by
        #4

        @Cosford Yes, I got it. I will look at it later this evening, since I have to go offline for couple of hours.

        For more information please re-read.

        Kind Regards,
        Artur

        1 Reply Last reply
        0
        • C Cosford

          Hi, thanks for your reply.

          SettingsWindow is indeed derived from QDialog.

          I assume I should make the slot/signal connection from MainWindow (where said button is a child of), although I'm unsure how to do this as SettingsWindow is an object held by the SettingsManager object, which along with MainWindow are both objects held by the ApplicationManager. Therefore, I don't believe that MainWindow can see the SettingsWindow, nor the SettingsManager object.

          I hope I've made myself clear enough?

          Regards,
          Cosford.

          artwawA Offline
          artwawA Offline
          artwaw
          wrote on last edited by
          #5

          @Cosford
          Hi, I apologize for late reply.
          I have read the documentation on session management and I would solve your problem by using applicationStateChanged signals to notify session manager that there are new data available for other applications in session and then other signal to MainWindow to let it know of the changes.
          Documentation suggests use of QSettings to store the data.

          Maybe there is someone with more experience in working with sessions that may have better solution but this is how would I try to make it work.

          For more information please re-read.

          Kind Regards,
          Artur

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

            Hi, thanks for the reply once again.

            I've had a look through the session manager documentation, but I'm not sure that will really be the sort of solution I'm looking for. All I believe I need to do is somehow expose the button signal from the main window UI object to the Application Manager which holds the MainWindow object, such that the Application Manager can connect that signal to the open slot on the SettingsWindow (if one exists).

            Regards,
            Cosford.

            artwawA 1 Reply Last reply
            0
            • C Cosford

              Hi, thanks for the reply once again.

              I've had a look through the session manager documentation, but I'm not sure that will really be the sort of solution I'm looking for. All I believe I need to do is somehow expose the button signal from the main window UI object to the Application Manager which holds the MainWindow object, such that the Application Manager can connect that signal to the open slot on the SettingsWindow (if one exists).

              Regards,
              Cosford.

              artwawA Offline
              artwawA Offline
              artwaw
              wrote on last edited by
              #7

              @Cosford As far as I understand you can do something like:
              button's signal --> triggers mainwindow's signal --> which is received by the app manager and triggers signal --> received by settings window

              At least that is what I understood from docs.

              I am sorry I cannot help more or test that solution for you but got urgent project on desktop right now.

              For more information please re-read.

              Kind Regards,
              Artur

              1 Reply Last reply
              0
              • C Offline
                C Offline
                Cosford
                wrote on last edited by
                #8

                Hi, thanks again.

                Trying to implement as you suggested. Slapping myself for not thinking of this before.

                I created in MainWindow a slot to receive the buttonPressed signal, which then emits a signal from the MainWindow. I'm attempting to connect this signal to the settingswindow show() slot.

                However, I'm running into a compilation issue;

                "C:\Users\Admin\Dropbox\QT\testProj\untitled\applicationmanager.cpp:10: error: C2665: 'QObject::connect' : none of the 3 overloads could convert all the argument types"

                The line of code causing this error is:
                QObject::connect(windowMain, SIGNAL(settingsButtonPressed()), managerSettings.windowSettings, SLOT(showWindow()));

                I'm somewhat confused on this one. It seems that the connect() function isn't recognising the SIGNAL(settingsButtonPressed()) argument. At least, I'm assuming that is the argument it's having an issue with as it doesn't show up in QtCreator's suggestions as I type it.

                The Signals and slots are defined correctly and work from within their own respective classes. It's just getting the ApplicationManager to see those signals/slots.

                artwawA 1 Reply Last reply
                0
                • C Cosford

                  Hi, thanks again.

                  Trying to implement as you suggested. Slapping myself for not thinking of this before.

                  I created in MainWindow a slot to receive the buttonPressed signal, which then emits a signal from the MainWindow. I'm attempting to connect this signal to the settingswindow show() slot.

                  However, I'm running into a compilation issue;

                  "C:\Users\Admin\Dropbox\QT\testProj\untitled\applicationmanager.cpp:10: error: C2665: 'QObject::connect' : none of the 3 overloads could convert all the argument types"

                  The line of code causing this error is:
                  QObject::connect(windowMain, SIGNAL(settingsButtonPressed()), managerSettings.windowSettings, SLOT(showWindow()));

                  I'm somewhat confused on this one. It seems that the connect() function isn't recognising the SIGNAL(settingsButtonPressed()) argument. At least, I'm assuming that is the argument it's having an issue with as it doesn't show up in QtCreator's suggestions as I type it.

                  The Signals and slots are defined correctly and work from within their own respective classes. It's just getting the ApplicationManager to see those signals/slots.

                  artwawA Offline
                  artwawA Offline
                  artwaw
                  wrote on last edited by
                  #9

                  @Cosford
                  In docs (QSessionManager::allowsInteraction) there is example:

                  MyMainWidget::MyMainWidget(QWidget *parent)
                      :QWidget(parent)
                  {
                      connect(qApp, SIGNAL(commitDataRequest(QSessionManager)), SLOT(commitData(QSessionManager)));
                  }
                  

                  but i don't know if that approach will solve your problem.
                  In other place (QApplication docs) may be a direct solution to what you've got:

                  void QApplication::commitDataRequest ( QSessionManager & manager ) [signal]
                  This signal deals with session management. It is emitted when the QSessionManager wants the application to commit all its data.

                  Usually this means saving all open files, after getting permission from the user. Furthermore you may want to provide a means by which the user can cancel the shutdown.

                  You should not exit the application within this signal. Instead, the session manager may or may not do this afterwards, depending on the context.

                  Warning: Within this signal, no user interaction is possible, unless you ask the manager for explicit permission. See QSessionManager::allowsInteraction() and QSessionManager::allowsErrorInteraction() for details and example usage.

                  Note: You should use Qt::DirectConnection when connecting to this signal.

                  This function was introduced in Qt 4.2.

                  See also isSessionRestored(), sessionId(), saveState(), and Session Management.

                  So, you shouldn't use QObject's connect but QApplication's (or QGuiApplication's) directConnect method.

                  Hope that helps a bit.

                  For more information please re-read.

                  Kind Regards,
                  Artur

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    Cosford
                    wrote on last edited by
                    #10

                    Hi, thanks once again.

                    I've now solved my issue. I achieved this by doing the following:

                    MainWindow:
                    -> Created Slot to receive button clicked signal and emit a signal.
                    -> Connected button click signal to above slot.

                    ApplicationManager:
                    -> Connected signal from MainWindow to SettingsWindow show slot.

                    Thanks for all your help and suggestions.

                    Regards,
                    Cosford.

                    artwawA 1 Reply Last reply
                    0
                    • C Cosford

                      Hi, thanks once again.

                      I've now solved my issue. I achieved this by doing the following:

                      MainWindow:
                      -> Created Slot to receive button clicked signal and emit a signal.
                      -> Connected button click signal to above slot.

                      ApplicationManager:
                      -> Connected signal from MainWindow to SettingsWindow show slot.

                      Thanks for all your help and suggestions.

                      Regards,
                      Cosford.

                      artwawA Offline
                      artwawA Offline
                      artwaw
                      wrote on last edited by
                      #11

                      @Cosford
                      I am happy to hear you made it.

                      If I helped in any way - my pleasure.

                      For more information please re-read.

                      Kind Regards,
                      Artur

                      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