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. Child window elements are blocked

Child window elements are blocked

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 2 Posters 757 Views 1 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.
  • H Offline
    H Offline
    Helg1980
    wrote on last edited by Helg1980
    #1

    Hi!

    I have three windows: MainWindow, SelectPreset, Preset.
    The SelectPreset window is called from the MainWindow window.
    And the Preset window is called from the SelectPreset window.
    But I can't understand why the Preset window elements are blocked (At the same time, this happens for some reason in Debian, in other systems I did not notice this).

    Here's how my files work:

    mainwindow.cpp

    MainWindow::MainWindow(QWidget *parent) : 
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    }
    .
    .
    .
    SelectPreset select_preset;
    select_preset.setModal(true);
    select_preset.exec();
    

    selectpreset.cpp

    SelectPreset::SelectPreset(QWidget *parent) :
        QDialog(parent),
        ui_selectpreset(new Ui::SelectPreset)
    {
        ui_selectpreset->setupUi(this);
    }
    .
    .
    .
    Preset preset;
    preset.setModal(true);
    preset.exec();
    

    preset.cpp

    Preset::Preset(QWidget *parent) :
        QDialog(parent),
        ui_preset(new Ui::Preset)
    {
        ui_preset->setupUi(this);
    }
    

    Screenshot_20201107_074111.png

    Pl45m4P 1 Reply Last reply
    0
    • H Helg1980

      Hi!

      I have three windows: MainWindow, SelectPreset, Preset.
      The SelectPreset window is called from the MainWindow window.
      And the Preset window is called from the SelectPreset window.
      But I can't understand why the Preset window elements are blocked (At the same time, this happens for some reason in Debian, in other systems I did not notice this).

      Here's how my files work:

      mainwindow.cpp

      MainWindow::MainWindow(QWidget *parent) : 
          QMainWindow(parent),
          ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
      }
      .
      .
      .
      SelectPreset select_preset;
      select_preset.setModal(true);
      select_preset.exec();
      

      selectpreset.cpp

      SelectPreset::SelectPreset(QWidget *parent) :
          QDialog(parent),
          ui_selectpreset(new Ui::SelectPreset)
      {
          ui_selectpreset->setupUi(this);
      }
      .
      .
      .
      Preset preset;
      preset.setModal(true);
      preset.exec();
      

      preset.cpp

      Preset::Preset(QWidget *parent) :
          QDialog(parent),
          ui_preset(new Ui::Preset)
      {
          ui_preset->setupUi(this);
      }
      

      Screenshot_20201107_074111.png

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @Helg1980

      Modal windows will start their own event loop and block other windows.

      exec will always start a new event loop and show a modal dialog. If you dont want modal windows, use show() for example.
      https://doc.qt.io/qt-5/qdialog.html#modal-prop


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      1
      • H Offline
        H Offline
        Helg1980
        wrote on last edited by
        #3

        I need the other windows to be blocked. But why is the current window blocked?

        Pl45m4P 1 Reply Last reply
        0
        • H Helg1980

          I need the other windows to be blocked. But why is the current window blocked?

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by
          #4

          @Helg1980

          Try to make Select Preset a parent of Preset by passing this with c'tor when creating Preset


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          1 Reply Last reply
          0
          • H Offline
            H Offline
            Helg1980
            wrote on last edited by Helg1980
            #5

            This command:
            ui_preset->setupUi(this);

            if I just remove 'this', it don't work

            Pl45m4P 1 Reply Last reply
            0
            • H Helg1980

              This command:
              ui_preset->setupUi(this);

              if I just remove 'this', it don't work

              Pl45m4P Offline
              Pl45m4P Offline
              Pl45m4
              wrote on last edited by
              #6

              @Helg1980

              I was talking about this:

              Preset preset;
              preset.setModal(true);
              preset.exec();

              Try: Preset preset(this);


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              1 Reply Last reply
              1
              • H Offline
                H Offline
                Helg1980
                wrote on last edited by
                #7

                It worked! Thank you very much!

                Pl45m4P 1 Reply Last reply
                1
                • H Helg1980

                  It worked! Thank you very much!

                  Pl45m4P Offline
                  Pl45m4P Offline
                  Pl45m4
                  wrote on last edited by
                  #8

                  @Helg1980

                  Nice to hear! Don't forget to mark your issue as solved.


                  If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                  ~E. W. Dijkstra

                  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