Modal loop issues inside Button "clicked"
-
Hello,
I'm using Qt quick controls to adapt an existing application. In a Button handler, I call a C++ function that enters a modal loop (tryed both a while(true) QApplication::processMessage or a new QEventLoop ).Once entered the loop, the button start misbehaving, i.e. everytime I click in any point of the screen (possibly another mouseArea), the click is still captured by the button (which may also be inactive) and more and more clicked events get generated improperly. It seems that the button keeps the mouse captured until you exit the clicked handler.
Any hint about this? Should I file a bug?I know that probably modal loops are not a good practice, but I need to adapt an existing application and fake some modal interfaces using qt quick (messageboxes, small dialogs,etc...) and I don't want to change all the application flow.
-
Hello, this bug still live... I do that way:
QObject* l_focusObject = qApp->focusObject(); if (l_focusObject) { QString l_className = QString::fromUtf8(l_focusObject->metaObject()->className()); if (!l_className.contains("Button", Qt::CaseInsensitive)) { qDebug() << "l_focusObject not button" << l_focusObject; l_focusObject = nullptr; } if (l_focusObject) { qDebug() << "l_focusObject disabled" << l_focusObject; l_oldValue = l_focusObject->property("enabled").toBool(); l_focusObject->setProperty("enabled", false); connect(l_focusObject, &QObject::destroyed, l_intData.eventLoop, [&l_focusObject]() { l_focusObject = nullptr; qDebug() << "l_focusObject destroyed"; }); } } l_eventLoop->exec(); if (l_focusObject) { qDebug() << "l_focusObject enabled" << l_focusObject; l_focusObject->setProperty("enabled", l_oldValue); }
May be I have to put more classes to handle on l_className filter...
How do you handle that?