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. How to open dialog box on top of the application if two screen are connected?

How to open dialog box on top of the application if two screen are connected?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qdialogsplashscreensplash
28 Posts 4 Posters 13.1k 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.
  • Y Offline
    Y Offline
    Yash001
    wrote on last edited by
    #6

    in addition, I try like
    QDialog* dialog = OBJ_NAME(new QDialog(m_mainWindow, Qt::SplashScreen), "notes-dialog");
    It is also create the same issue.

    only setParent is work fine.

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

      Hi,

      Why not use this rather than m_mainWindow ?

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

      Y 1 Reply Last reply
      1
      • Y Yash001

        in addition, I try like
        QDialog* dialog = OBJ_NAME(new QDialog(m_mainWindow, Qt::SplashScreen), "notes-dialog");
        It is also create the same issue.

        only setParent is work fine.

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #8

        @Yash001
        and you have like
        ShowDataRecoveryInformDialog::ShowDataRecoveryInformDialog(QWidget *parent) : QDialog (parent)

        in your dialog so you forward parent to base?

        Y 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Why not use this rather than m_mainWindow ?

          Y Offline
          Y Offline
          Yash001
          wrote on last edited by
          #9

          @SGaist I already try it but it is not work. i got this error.

          Severity Code Description Project File Line Suppression State
          Error C2664 'void QWidget::setParent(QWidget *,Qt::WindowFlags)': cannot convert argument 1 from 'MainWindowUI *const ' to 'QWidget *'

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

            Can you show your complete code for your MainWindow ?

            It looks like you are modifying the wrong file.

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

            Y 1 Reply Last reply
            0
            • mrjjM mrjj

              @Yash001
              and you have like
              ShowDataRecoveryInformDialog::ShowDataRecoveryInformDialog(QWidget *parent) : QDialog (parent)

              in your dialog so you forward parent to base?

              Y Offline
              Y Offline
              Yash001
              wrote on last edited by
              #11

              @mrjj
              m_mainWindow is my main Object, it is create the whole application on GUI side by calling createUI funcation.

              yes i was try to set the parent as main object.

              I make this change and code work perfectly fine. and got the output, which I want.

              void MainWindowUI::ShowDataRecoveryInformDialog() {
              QDialog dialog = new QDialog( );

              dialog->setWindowFlags(Qt::SplashScreen);
              dialog->setParent(m_mainWindow);

              auto dialogLay = new QVBoxLayout(dialog);
              dialogLay->addWidget(PBT("button 1"));
              dialogLay->addWidget(PBT("button 2"));
              dialog->exec();
              }

              1 Reply Last reply
              0
              • SGaistS SGaist

                Can you show your complete code for your MainWindow ?

                It looks like you are modifying the wrong file.

                Y Offline
                Y Offline
                Yash001
                wrote on last edited by
                #12

                @SGaist by using setParent and set WindowFlag property. i am able to open dialog on top of the Application.

                dialog->setWindowFlags(Qt::SplashScreen);
                dialog->setParent(m_mainWindow);

                Thank you Sir for your help.

                1 Reply Last reply
                0
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #13

                  Ok should be the same as, or else im very wondering

                  void MainWindowUI::ShowDataRecoveryInformDialog() {
                  QDialog dialog = new QDialog( m_mainWindow);
                  dialog->setWindowFlags(Qt::SplashScreen);
                  auto dialogLay = new QVBoxLayout(dialog);
                  dialogLay->addWidget(PBT("button 1"));
                  dialogLay->addWidget(PBT("button 2"));
                  dialog->exec();
                  }
                  
                  Y 1 Reply Last reply
                  0
                  • mrjjM mrjj

                    Ok should be the same as, or else im very wondering

                    void MainWindowUI::ShowDataRecoveryInformDialog() {
                    QDialog dialog = new QDialog( m_mainWindow);
                    dialog->setWindowFlags(Qt::SplashScreen);
                    auto dialogLay = new QVBoxLayout(dialog);
                    dialogLay->addWidget(PBT("button 1"));
                    dialogLay->addWidget(PBT("button 2"));
                    dialog->exec();
                    }
                    
                    Y Offline
                    Y Offline
                    Yash001
                    wrote on last edited by
                    #14

                    @mrjj

                    I don't know. what is different but now it is work. i did not make any change except setting the property

                    before:
                    QDialog *dialog = new QDialog(parent, Qt::SplashScreen);

                    now :

                    QDialog* dialog = new QDialog();
                    dialog->setWindowFlags(Qt::SplashScreen);
                    dialog->setParent(m_mainWindow);

                    mrjjM 1 Reply Last reply
                    0
                    • Y Yash001

                      @mrjj

                      I don't know. what is different but now it is work. i did not make any change except setting the property

                      before:
                      QDialog *dialog = new QDialog(parent, Qt::SplashScreen);

                      now :

                      QDialog* dialog = new QDialog();
                      dialog->setWindowFlags(Qt::SplashScreen);
                      dialog->setParent(m_mainWindow);

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #15

                      @Yash001
                      ok, im not sure either. seems the same :)

                      1 Reply Last reply
                      0
                      • Y Offline
                        Y Offline
                        Yash001
                        wrote on last edited by
                        #16

                        I found the different.

                        it is work fine.

                        dialog->setWindowFlags(Qt::SplashScreen);
                        dialog->setParent(m_mainWindow);

                        it is not work.

                        dialog->setParent(m_mainWindow);
                        dialog->setWindowFlags(Qt::SplashScreen);

                        mrjjM 1 Reply Last reply
                        1
                        • Y Yash001

                          I found the different.

                          it is work fine.

                          dialog->setWindowFlags(Qt::SplashScreen);
                          dialog->setParent(m_mainWindow);

                          it is not work.

                          dialog->setParent(m_mainWindow);
                          dialog->setWindowFlags(Qt::SplashScreen);

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #17

                          @Yash001
                          Ok so Qt::SplashScreen does something with parent.

                          Y 1 Reply Last reply
                          0
                          • mrjjM mrjj

                            @Yash001
                            Ok so Qt::SplashScreen does something with parent.

                            Y Offline
                            Y Offline
                            Yash001
                            wrote on last edited by
                            #18

                            @mrjj May be. It is qt default function.

                            mrjjM 1 Reply Last reply
                            0
                            • Y Yash001

                              @mrjj May be. It is qt default function.

                              mrjjM Offline
                              mrjjM Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on last edited by
                              #19

                              @Yash001
                              yeah its a windows flag.

                              Y 1 Reply Last reply
                              0
                              • mrjjM mrjj

                                @Yash001
                                yeah its a windows flag.

                                Y Offline
                                Y Offline
                                Yash001
                                wrote on last edited by
                                #20

                                @mrjj

                                dialog->setWindowFlags(Qt::SplashScreen);
                                dialog->setParent(m_mainWindow);
                                In this case I got dialog box on top of the screen but it is make another issue

                                dialog->exec(); is not work as per expectation. without responding the to Dialog user access the other page also.

                                In other word, user can access both screen Main application as well as Dialog box. how to block access on other widget until get response from the user in dialog box?

                                mrjjM 1 Reply Last reply
                                0
                                • Y Yash001

                                  @mrjj

                                  dialog->setWindowFlags(Qt::SplashScreen);
                                  dialog->setParent(m_mainWindow);
                                  In this case I got dialog box on top of the screen but it is make another issue

                                  dialog->exec(); is not work as per expectation. without responding the to Dialog user access the other page also.

                                  In other word, user can access both screen Main application as well as Dialog box. how to block access on other widget until get response from the user in dialog box?

                                  mrjjM Offline
                                  mrjjM Offline
                                  mrjj
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #21

                                  Hi
                                  Im not 100% sure Qt::SplashScreen is compatiple with Qt::Dialog flag

                                  Qt::SplashScreen 0x0000000e | Window Indicates that the window is a splash screen. This is the default type for QSplashScreen.

                                  Normally used with QSplashScreen widget.

                                  1 Reply Last reply
                                  0
                                  • mrjjM Offline
                                    mrjjM Offline
                                    mrjj
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #22

                                    maybe try with
                                    dialog->setWindowFlags(Qt::Dialog | Qt::SplashScreen);

                                    1 Reply Last reply
                                    0
                                    • Y Offline
                                      Y Offline
                                      Yash001
                                      wrote on last edited by
                                      #23

                                      @mrjj it is create previous issue.

                                      mrjjM JonBJ 2 Replies Last reply
                                      0
                                      • Y Yash001

                                        @mrjj it is create previous issue.

                                        mrjjM Offline
                                        mrjjM Offline
                                        mrjj
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #24

                                        @Yash001
                                        but why you need Qt::SplashScreen ?
                                        and modal dialog ?
                                        cant you just use the dialog ?

                                        1 Reply Last reply
                                        1
                                        • Y Yash001

                                          @mrjj it is create previous issue.

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

                                          @Yash001
                                          Similarly to @mrjj , have you considered using QSplashScreen (http://doc.qt.io/qt-5/qsplashscreen.html), maybe it doesn't have these problems?

                                          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