Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Prevent dialog from getting input
Qt 6.11 is out! See what's new in the release blog

Prevent dialog from getting input

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
13 Posts 3 Posters 5.5k 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.
  • J Offline
    J Offline
    jigarp
    wrote on last edited by
    #1

    Hello,

    I've two screen where parent size is 0,0,480,272 while child is at 60,56,240,130

    When child is open parent can be touched.
    How to prevent this?
    I want that touch are eligible only for the top dialog

    JonBJ 1 Reply Last reply
    0
    • J jigarp

      Hello,

      I've two screen where parent size is 0,0,480,272 while child is at 60,56,240,130

      When child is open parent can be touched.
      How to prevent this?
      I want that touch are eligible only for the top dialog

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

      @jigarp
      Code? Is your dialog modal? QDialog::exec()? etc.

      J 1 Reply Last reply
      2
      • JonBJ JonB

        @jigarp
        Code? Is your dialog modal? QDialog::exec()? etc.

        J Offline
        J Offline
        jigarp
        wrote on last edited by
        #3

        @JonB
        No.
        I don't how to use it??

        jsulmJ 1 Reply Last reply
        0
        • J jigarp

          @JonB
          No.
          I don't how to use it??

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @jigarp How to use what? exec()?
          Check documentation: http://doc.qt.io/qt-5/qdialog.html#exec
          This is called a modal dialog: a modal dialog blocks all other windows of the application as long as it is shown.
          Using exec() instead of show() you can make your dialog modal.
          Like (again) shown in documentation:

          void EditorWindow::countWords()
          {
              WordCountDialog dialog(this);
              dialog.setWordCount(document().wordCount());
              dialog.exec();
          }
          

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2
          • J Offline
            J Offline
            jigarp
            wrote on last edited by jigarp
            #5

            @jsulm
            In My case i've creted all the diaglog on startup.
            While button presssed i'm showing dialog.
            This time i've used
            dialog.exec();
            instead of show but still background screens can accept touch events.
            Here my

            jsulmJ 1 Reply Last reply
            0
            • J jigarp

              @jsulm
              In My case i've creted all the diaglog on startup.
              While button presssed i'm showing dialog.
              This time i've used
              dialog.exec();
              instead of show but still background screens can accept touch events.
              Here my

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @jigarp What "background screens"? Do you mean other applications or your own application where you start this dialog?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              J 1 Reply Last reply
              0
              • jsulmJ jsulm

                @jigarp What "background screens"? Do you mean other applications or your own application where you start this dialog?

                J Offline
                J Offline
                jigarp
                wrote on last edited by
                #7

                @jsulm
                In same application different dialog

                jsulmJ 1 Reply Last reply
                0
                • J jigarp

                  @jsulm
                  In same application different dialog

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @jigarp In what way do these other dialogs accept touch events?

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  J 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @jigarp In what way do these other dialogs accept touch events?

                    J Offline
                    J Offline
                    jigarp
                    wrote on last edited by jigarp
                    #9

                    @jsulm
                    Here i've provided my sample code.
                    You may get an idea from this that how my code is working

                    Parent Window resolution 0,0,480,272

                    MainWindow::MainWindow(QWidget *parent) :
                        QMainWindow(parent),
                        ui(new Ui::MainWindow)
                    {
                        ui->setupUi(this);
                        sibling1Child = new sibling1(this);
                    
                        this->move(0,0);            // 0,0,480,272
                        sibling1Child->move(0,0);   // 0,0,480,272
                    }
                    
                    MainWindow::~MainWindow()
                    {
                        delete ui;
                    }
                    
                    void MainWindow::on_pushButton_pressed()
                    {
                        sibling1Child->show();
                    }
                    

                    Sibling 1 resolution 0,0,480,272

                    
                    sibling1::sibling1(QWidget *parent) :
                        QDialog(parent),
                        ui(new Ui::sibling1)
                    {
                        ui->setupUi(this);
                        sibling2Child = new sibling2(this);
                        sibling2Child->move(60,56); // 60,56,240,130
                    
                    }
                    
                    sibling1::~sibling1()
                    {
                        delete ui;
                    }
                    
                    
                    void sibling1::on_pushButton_2_pressed()
                    {
                        sibling2Child->move(60,56);
                        sibling2Child->show();
                    }
                    
                    void sibling1::on_pushButton_pressed()
                    {
                        this->hide();
                    }
                    
                    

                    sibling2 resolution 60,56,240,130

                    sibling2::sibling2(QWidget *parent) :
                        QDialog(parent),
                        ui(new Ui::sibling2)
                    {
                        ui->setupUi(this);
                    }
                    
                    sibling2::~sibling2()
                    {
                        delete ui;
                    }
                    
                    void sibling2::on_pushButton_pressed()
                    {
                        this->hide();
                    }
                    
                    jsulmJ 1 Reply Last reply
                    0
                    • J jigarp

                      @jsulm
                      Here i've provided my sample code.
                      You may get an idea from this that how my code is working

                      Parent Window resolution 0,0,480,272

                      MainWindow::MainWindow(QWidget *parent) :
                          QMainWindow(parent),
                          ui(new Ui::MainWindow)
                      {
                          ui->setupUi(this);
                          sibling1Child = new sibling1(this);
                      
                          this->move(0,0);            // 0,0,480,272
                          sibling1Child->move(0,0);   // 0,0,480,272
                      }
                      
                      MainWindow::~MainWindow()
                      {
                          delete ui;
                      }
                      
                      void MainWindow::on_pushButton_pressed()
                      {
                          sibling1Child->show();
                      }
                      

                      Sibling 1 resolution 0,0,480,272

                      
                      sibling1::sibling1(QWidget *parent) :
                          QDialog(parent),
                          ui(new Ui::sibling1)
                      {
                          ui->setupUi(this);
                          sibling2Child = new sibling2(this);
                          sibling2Child->move(60,56); // 60,56,240,130
                      
                      }
                      
                      sibling1::~sibling1()
                      {
                          delete ui;
                      }
                      
                      
                      void sibling1::on_pushButton_2_pressed()
                      {
                          sibling2Child->move(60,56);
                          sibling2Child->show();
                      }
                      
                      void sibling1::on_pushButton_pressed()
                      {
                          this->hide();
                      }
                      
                      

                      sibling2 resolution 60,56,240,130

                      sibling2::sibling2(QWidget *parent) :
                          QDialog(parent),
                          ui(new Ui::sibling2)
                      {
                          ui->setupUi(this);
                      }
                      
                      sibling2::~sibling2()
                      {
                          delete ui;
                      }
                      
                      void sibling2::on_pushButton_pressed()
                      {
                          this->hide();
                      }
                      
                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @jigarp More interesting information is: how do you show the dialogs?

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      J 1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @jigarp More interesting information is: how do you show the dialogs?

                        J Offline
                        J Offline
                        jigarp
                        wrote on last edited by jigarp
                        #11

                        @jsulm
                        Can you please ellaborate it..
                        is it like
                        show() or hide() functions.

                        Else as you mentioned using dialog.exec() function.
                        I've tried both of them

                        jsulmJ 1 Reply Last reply
                        0
                        • J jigarp

                          @jsulm
                          Can you please ellaborate it..
                          is it like
                          show() or hide() functions.

                          Else as you mentioned using dialog.exec() function.
                          I've tried both of them

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @jigarp Well, if you show a dialog using exec() then it should block all other dialogs and main window.

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          J 1 Reply Last reply
                          0
                          • jsulmJ jsulm

                            @jigarp Well, if you show a dialog using exec() then it should block all other dialogs and main window.

                            J Offline
                            J Offline
                            jigarp
                            wrote on last edited by
                            #13

                            @jsulm
                            I've replaced show() with exec()
                            But still not working.

                            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