c++ - How to prevent double slot invocation when showing a QMessageBox? -


i've connected editingfinished signal of qlineedit slot in application showing qmessagebox if input in way unexpected. strangely enough message box shown twice, put breakpoint executed , had @ stack trace. there qmessagebox.exec() calls qapplication::processevents() seems somehow forward , process same event again.

my stack trace first time looks sth this:

myapp::myslot() qlineedit::editingfinished() qguiapplicationprivate::processmouseevent() qeventloop::processevents() qapplication::exec() 

and 2nd time this:

myapp::myslot() qlineedit::editingfinished() qguiapplicationprivate::processwindowsystemevent() qeventloop::processevents() qdialog::exec() // stack trace of run #1 here // [...] 

i've checked double signal connections or different events being connected slot doesn't seem problem. can explain happens here , how prevent it?

it qt bug editingfinished emitted twice, can read here:

https://forum.qt.io/topic/39141/qlineedit-editingfinished-signal-is-emitted-twice

there workaround described.

if(lineedit->text().todouble()<1000) { lineedit->blocksignals(true); qmessagebox::information(this, "information", "incorrect value"); lineedit->blocksignals(false); } 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -