PDA

View Full Version : Basically signals-slot application



Daxos
27th May 2010, 11:58
Hi,
i have a problem.
I have an application whit 6 different lineEdit. Each lineedit rapresent a field of my personal database.

The goal is:
when the text in a lineEdt is modify i would writing the new value on my database.
For solve this task i have create a signal-slot architecture: i have connected the signal "editingFinished" whit my personal slot.

The problem is that in the application there are 6 different lineEdit that can emit "editingFinished".

How i can recognize a specific lineEdit? I have try using the sender() function but my object that emit this signal is all lineEdit.

Can anyone help me, please???

Thanks!
Dax

tbscope
27th May 2010, 12:06
How i can recognize a specific lineEdit? I have try using the sender() function but my object that emit this signal is all lineEdit.

Example:

QLineEdit *theSendingLineEdit = static_cast<QLineEdit*>(sender());

But I suggest you look into QSignalMapper

Daxos
27th May 2010, 13:32
Example:

QLineEdit *theSendingLineEdit = static_cast<QLineEdit*>(sender());

But I suggest you look into QSignalMapper

Ok thaks, but i have another problem:

Fro example assume that i have this situation:
first LineEdit: Name
second LineEdit: Surname

Both the value of the linEdit is QString.

Whit this method i have the current lineEdit that have emitted the signal, but i don't know if is the linEdit Surname or the lineEdit Name. But this is very important for me because i want save the lineEdit's value in my database

tbscope
27th May 2010, 13:38
QSignalMapper will tell you exactly which widget it is.
Check out the examples

Daxos
27th May 2010, 13:56
Ok thanks for the reply!!!