[Interest] QGuiApplication::commitDataRequest: QML window is not painted

Alexander Dyagilev alervdvcw at gmail.com
Tue Mar 2 20:31:11 CET 2021


So, finally I had to switch to QMessageBox for this case. QML window is 
just not updated without user interaction due to an unknown reason....


On 2/27/2021 4:52 PM, Alexander Dyagilev wrote:
>
> Hello,
>
> I'm trying to add quit confirmation message at OS shutdown according 
> to this example:
> https://doc.qt.io/qt-5/qsessionmanager.html#allowsInteraction
>
> I interact with the user via QML interface. It is asynchronous, so I 
> use slots/signals. And I use additional QEventLoop to stay inside of 
> QGuiApplication::commitDataRequest call while interacting with the user.
>
> The trouble is that after I shutdown OS - my app prevents OS to 
> shutdown and it's good, but its screen is just white, or contains old 
> state without the confirmation dialog. I need to hide/restore window 
> or change its size, or do some mouse clicks inside of it to force it 
> repaint. When it repaint all is OK and my confirmation dialog is there.
>
> Is this a bug? Is there a workaround?
>
> This is the code I use:
>
> voidAppQuitConfirmationAtOsShutdownManager::onCommitDataRequest(
>
> QSessionManager&m)
> {
> Q_ASSERT_SAME_THREAD;
> if(!m_ui->isConfirmationRequired())
> return;
> if(!m.allowsInteraction())
> return;
> boolisConfirmed=true;
> QEventLooploop;
> qtconnect(m_ui.data(),&AppQuitConfirmationUiManager::confirmationResult,
> &loop,[&](boolconfirmed)
> {
> isConfirmed=confirmed;
> loop.quit();
> },
> Qt::QueuedConnection);
> m_ui->requestConfirmation();
> loop.exec();
> m.release();
> if(!isConfirmed)
> m.cancel();
> }
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20210302/ef520e7a/attachment.html>


More information about the Interest mailing list