The main window does not receive events after closing the modal dialog

My application was QT encoded and running on an Android device. There is a button in the main windows of my application. When the user clicks on this button, my application will display a user dialog (modal):

progressDialog = new QDialog(this);
...
progressDialog->setObjectName("processingDialog");
progressDialog->setModal(true);
progressDialog->show();

when the processing is completed, I want to hide this modal dialog and set the focus back to the main window:

progressDialog->close();
this->setFocus();
this->activateWindow();

But when I launch on my Android device when the modal dialog is closed, my main window does not receive the event (tab, touch, slide). When I click on the screen once, my main window seems to be working fine

Please help me solve this problem. thank you

I apologize if my question makes it difficult to understand.

+4
2

Android - , .

, -, , QStackedWidget, .

:

class W1 : public QWidget {
    Q_OBJECT
public:
    W1(QWidget * p = 0) : QWidget(p) {
        QVBoxLayout * l = new QVBoxLayout(this);
        setLayout(l);
        QPushButton * b = new QPushButton("do work", this);
        l->addWidget(b);
        l->addSpacerItem(new QSpacerItem(1, 600));
        connect(b, SIGNAL(clicked(bool)), parent(), SLOT(showBusyDialog()));
    }
};

class W2 : public QWidget {
    Q_OBJECT
public:
    W2(QWidget * p = 0) : QWidget(p) {
        setAttribute(Qt::WA_OpaquePaintEvent, true);
        setAttribute(Qt::WA_NoSystemBackground);
        QVBoxLayout * l = new QVBoxLayout(this);
        setLayout(l);
        QLabel * lb = new QLabel("...working, please wait...", this);    
        l->addWidget(lb);
        l->setAlignment(lb, Qt::AlignCenter);
    }    
    void paintEvent(QPaintEvent * ) {
        QPainter p(this);
        p.fillRect(rect(), QColor(0, 0, 0, 128));
    }
};

class MainW : public QStackedWidget {
    Q_OBJECT
public:
    MainW() {
        resize(300, 600);
        W1 * w1 = new W1(this);
        addWidget(w1);
    }
public slots:
    void showBusyDialog() {
        W2 * w2 = new W2(this);
        setCurrentIndex(addWidget(w2));
        QTimer::singleShot(2000, w2, SLOT(deleteLater()));
    }
};

W1, " ", 2 , "" ". .

, , , - " " - . , , , , .

+3

progressDialog.dismiss(); .close();

-2

All Articles