In some programs I have to deal with daily this is the only state of mind available to someone expecting sane behaviour from the program.![]()
In some programs I have to deal with daily this is the only state of mind available to someone expecting sane behaviour from the program.![]()
Thanks guys. As you mentioned the possibility of concurrency is not there as only one thread is involved. I'll try to implement a custom dialog with preferred modality for the same functionality. For using disable/enable strategy, I'll have to disable all the buttons in response to one click because furious clicking may be spread across multiple buttons. I don't want to do this.
I modified my slot function to
But I see the same behavior on furious clicking of the button. Multiple message boxes pop up. "message.setWindowModality(Qt::ApplicationModa l)" doesn't seem to have any effect on android. What could be happening here?Qt Code:
void slotFunction() { QMessageBox message; message.setWindowModality(Qt::ApplicationModal); message.setWindowTitle("...."); message.setDetailedText("...."); message.exec(); }To copy to clipboard, switch view to plain text mode
It could be happening that Android does not support application modal dialogs. Why don't you disable the UI yourself as was already suggested?
I tried two things
1. Created the messageBox in the constructor and assigned parent to the main window
This seems to solve the problem of multiple boxes opening. But still on furious clicking, flickering is observed in the message box as if one opened over another even though there is only one box opened in effect. Why should this behavior be there?Qt Code:
constructor() { messageBox->setWindowModality(Qt::ApplicationModal); } void slotFunction() { messageBox->setWindowTitle("...."); messageBox->setDetailedText("...."); messageBox->exec(); }To copy to clipboard, switch view to plain text mode
2. disable/enable the UI. The components become grayed out on disable. Sometime I observe that on closing the message box, the components take a while to return from grayed out state to normal state, which looks odd. Is there a way to control how a widget looks in disabled state?
Yes but that would be an overkill if you ask me.
And your first approach is dangerous as you are execing the dialog while already in exec. Better set a flag before calling exec and bail out from the function if at the beginning the flag is already set.
Qt Code:
void slotFunction() { if(dialogExecuting) return; dialogExecuting = true; messageBox->setWindowTitle("...."); messageBox->setDetailedText("...."); messageBox->exec(); dialogExecuting = false; }To copy to clipboard, switch view to plain text mode
"you are execing the dialog while already in exec".. I don't understand this. The mentioned constructor is of the mainwindow and messagebox is a member of the mainwindow and slotFunction corresponds to a pushbutton in the mainwindow. MessageBox->setWindowModality(Qt::ApplicationModal) takes effect only when the messagebox's parent is set to the calling widget.
To the first approach, I added disableUI before executing messagebox and enableUI after the messagebox is done. This works fine.. And regarding the disabled state of UI components, I was able to control them through the styleSheet (QPushButton:disabled {....}). But some other issues are observed. The moment I add a standardbutton say 'Ok' to the messagebox the BackKey which is supposed to quit the messagebox doesnt work. And if the text in the messagebox is too long and doesn't fit in the screen, the same can be viewed by scrolling. The issue is, to reach the 'Ok' button also I need to scroll down completely. It isn't visible on the screen until I scroll through the text completely. Weird behavior. Any ideas?
Bookmarks