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. [SOLVED]How do I know that the window is fully displayed on the screen

[SOLVED]How do I know that the window is fully displayed on the screen

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 3.8k 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.
  • E Offline
    E Offline
    Elijah Green
    wrote on last edited by
    #1

    I need do some actions when my main window if fully painted on screen.
    For this i tryed use showEvent:
    @void MyMainWindow::showEvent(QShowEvent *event)
    {
    QMainWindow::showEvent(event);

    if(event->spontaneous() || isWindowLoaded)
    return;

    SomeCreatedDilalog->exec();

    isWindowLoaded = true;
    }@
    But when i am use this code SomeCreatedDialog is shown on screen before MainWindow.
    This dialog is modal, so i must close it. And only after this MainWindow will displaed.

    And my question: How i can display MainWindow on screen and only after this display modal dilaog?

    1 Reply Last reply
    0
    • E Offline
      E Offline
      Elijah Green
      wrote on last edited by
      #2

      Okay... I think i can do what i want with handaling WindowActivate event:
      @bool MainWindow::event(QEvent* ev)
      {
      //qDebug()<<ev->type();
      bool isHandled = QMainWindow::event(ev);
      if(isHandled)
      {
      // Emit signal when window activated in first.
      if(ev->type() == QEvent::WindowActivate && !isWindowLoaded)
      {
      qDebug()<<isWindowLoaded;
      qDebug()<<ev->type();
      isWindowLoaded = true;
      emit MainWindowShown();
      }
      }
      return isHandled;
      }@

      Maybe someone know best solution?

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

        In MyMainWindow::showEvent fire a single shot timer connected to some slot say execDialog. In this slot call "SomeCreatedDilalog->exec()"

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lgeyer
          wrote on last edited by
          #4

          Well, what about ... ?
          @
          MainWindow mainWindow;
          mainWindow.show();

          Dialog dialog;
          dialog.exec();

          ...
          @

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

            @Lukas, obviously your solution is the most viable, but from what I understand, @Elijah has called MainWindow :: show(). Maybe I don't understand exactly :-)

            1 Reply Last reply
            0
            • E Offline
              E Offline
              Elijah Green
              wrote on last edited by
              #6

              Lukas, cincirin Yes this silution is most viable - but does not work for me.
              How i say before i need modal dialog, so i must show this dialog with exec() method (not show()).
              And if i have this main function:
              @int main(int argc, char argv[])
              {
              QApplication a(argc, argv);
              MainWindow mw;
              mw.show();
              Dialog
              dlg = new Dialog(&mw); //It is modal for his parrent
              dlg->exec();
              return a.
              }@
              This solution perfect.

              But i need call modal dialog in his parent class. And immediately after show parent.
              I need it for encapsulation.
              Okay, i can solve my problem with your solution but i think it is bad for my encapsulation.

              1 Reply Last reply
              0
              • C Offline
                C Offline
                cincirin
                wrote on last edited by
                #7

                Ok, then the solution with the single shot timer does not work ?
                @
                MainWindow::::showEvent(QShowEvent *event)
                {
                QMainWindow::showEvent(event);
                QTimer::singleShot(0, this, SLOT(dialogExec));
                }
                @

                Then in dialogExec slot, call yourDialog->exec()

                1 Reply Last reply
                0
                • E Offline
                  E Offline
                  Elijah Green
                  wrote on last edited by
                  #8

                  Greate. This solution more suitable for me.
                  Thanks to all.

                  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