Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QDialog CloseEvent



  • Hello Friends And Qt Experts

    I Want to connect close Event for my QDialog Box
    Here My Code::

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    
    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
        , ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    void MainWindow::closeEvent(QCloseEvent *event)
    {
        if(event->type() == QEvent::Close)
        {
            event->ignore();
            QMessageBox::information(this, " ", "Close Event Call");
        }
    }
    
    void MainWindow::on_pushButton_clicked()
    {
        Dlg = new QDialog(this); /// I want to Disable Alt+F4 Key
        Dlg->installEventFilter(this);
        Dlg->setMinimumWidth(250);
        Dlg->setMaximumWidth(250);
        Dlg->setMinimumHeight(250);
        Dlg->setMaximumHeight(250);
        Dlg->show();
    }
    
    

    i want to disable Alt+F4 Key for my QDialog Box

    right now when my QDialog Box is open that time i am pressing Alt+F4 Key and my QDialog Box is closed.
    but when i try to close my MainWindow using Alt+F4 Key that time i got My Message From closeEvent Function

    Please Help me to solve this problem.
    Thanks in Advance.




Log in to reply