PDA

View Full Version : Ignoring "editingFinished" when closing application



^NyAw^
10th April 2008, 16:00
Hi,

I have an application that contains a QLineEdit and a slot that recives "editingFinished" from this QLineEdit.
When closing the application using "X" button, the signal is emmited and the slot is called. In this case I want to ignore this signal. Is it possible?

Thanks,

Lykurg
10th April 2008, 18:30
Hi,

I don't exactly know if it will work, but try

//main.cpp
..
QApplication a(argc, argv);
...
a.connect(&a, SIGNAL(lastWindowClosed()), yourMainClass, SLOT(yourQuitSlot()));
...

and look if you can disconnect the connection from your QLineEdit bevor "editingFinished" is emitted.


Lykurg

^NyAw^
10th April 2008, 18:37
Hi,

Don't think would work because the focus of QLineEdit is lost(producing editFinished) before the close signal is emmited.

Thanks,

jpn
10th April 2008, 18:52
Override closeEvent() of the window and call QObject::blockSignals(true) on the line edit.

^NyAw^
10th April 2008, 23:03
Hi,

Thanks, works perfectly.

^NyAw^
15th April 2008, 16:40
Hi,

I have another problem:
When I change the application using the mouse or Alt+Tab:
The QLineEdit let's me introduce a code. This code is used as index to get information from a QList. If I have no text on the QLineEdit and change the application, the QLineEdit emits a finishEdit signal that tries to index the QList, and as it don't find the code, I make a QMessageBox that show that the "Code introduced" is not valid. This QMessageBox is showed many times until the application hangs.

I use this approach because I want a step by step application(without QWizard), that the first step is to get the information indexed by the code introduced.

Thanks,