Fabiolamb / CalMoney_Using-Qt-for-FullPlatform

A cross-platform, Qt6 C++ Widget for calculating payroll by hours and minutes worked.
BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

cannot refresh immediately #1

Closed Fabiolamb closed 2 months ago

Fabiolamb commented 2 months ago

On Android, clicking on some widgets like buttons and calendars is not responsive enough, and you even need to click again somewhere else to respond. Overall, it doesn't refresh in a timely manner.

Fabiolamb commented 2 months ago

On Android, clicking on some widgets like buttons and calendars is not responsive enough, and you even need to click again somewhere else to respond. Overall, it doesn't refresh in a timely manner.

With these three lines of code

viewDialog->activateWindow();
viewDialog->raise();
QApplication::processEvents();

This solves the problem. Why? viewDialog->activateWindow(); This line of code sets the window as active. It sets the focus of the window to the current dialog, making it the window the user is currently interacting with. Normally, the window manager switches the focus to that window and places it on top of other windows. viewDialog->raise(); This line of code places the window at the top of the stack, making it appear above the other windows. This is useful for making sure that a dialog window is displayed in front of other windows, especially in multi-window applications. QApplication::processEvents(). This line of code forces all pending events to be processed in the event loop, which is used by Qt applications to process user input, drawing events, and other asynchronous tasks. Typically, the event loop is processed automatically in the main loop of the application, but sometimes it needs to be forced at specific points in time to ensure timely responses and updates to the interface. In practice, however, I think viewDialog->activateWindow() is the line that has a role to play, as can be demonstrated by a simple test.