Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Weirdest behavior of a modal window when the parent is in move/size loop.
Qt 6.12 LTS is out! See what's new in the release blog

Weirdest behavior of a modal window when the parent is in move/size loop.

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.2k 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.
  • N Offline
    N Offline
    nikitablack
    wrote on last edited by
    #1

    Greetings.

    Please take a look at the following code:

    // MainWindow.h
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    #include "MainWindow.h"
    #include "ui_mainwindow.h"
    #include <QTimer>
    #include <QErrorMessage>
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    public:
        explicit MainWindow(QWidget *parent = 0) : QMainWindow(parent), ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
            QTimer::singleShot(2000, this, &MainWindow::showChildWindow);
        }
    
        ~MainWindow()
        {
            delete ui;
        }
    private:
        Ui::MainWindow *ui;
    
        void showChildWindow()
        {
            QErrorMessage* err{new QErrorMessage{this}};
            err->setWindowModality(Qt::ApplicationModal);
            err->showMessage("Test");
            err->setGeometry(100, 100, 300, 300);
            err->exec();
        }
    };
    
    #endif // MAINWINDOW_H
    

    At the first look it seems ok. It's even works ok until you try to move/resize it before QErrorMessage appear. If this message was showed during such loop (move/size modal loop) then this message becomes disabled for moving/resizing also. Moreover, after closing it the parent window jumps to the previos position what looks jerky.

    1 Reply Last reply
    0
    • N Offline
      N Offline
      nikitablack
      wrote on last edited by
      #2

      I tried to do the same with native Windows windows and it looks like that operating system works this way. Native modal windows are also inactive for dragging/resizing if was created during parent move/resize.

      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
      • Unsolved