1 Attachment(s)
How to write the "Enter" event
Hello everyone,
I have a dialog box as a child of a parent widget.Iam sending the snapshot of the dialog box.
When a string is entered in the lineedit and "enter" key is pressed, the "forward" button should work which is not happenning with my code. Can any body help me in this regard.
Thanks & Regards,
Sarma.
Re: How to write the "Enter" event
Code:
connect(lineEdit, SIGNAL(returnPressed()), fwdButton, SIGNAL(clicked()));
[EDIT] Changed SLOT->SIGNAL, thanks wysota for pointing this out ;)
Re: How to write the "Enter" event
hi sarma,
could u resend the screenshot again...i guess it didnt get attached:)
Cheers,
Amulya
Re: How to write the "Enter" event
sorry...disregard my above post:p
Re: How to write the "Enter" event
Set "Forward" as the default button (setDefault(true) on the button).
Re: How to write the "Enter" event
Iam sorry to say this that both the methods are suggested above are not working.
Quote:
Originally Posted by jpn
connect(lineEdit, SIGNAL(returnPressed()), fwdButton, SLOT(clicked()));
This is showing two errors as:
Quote:
QObject::connect: (sender name: 'unnamed')
QObject::connect: (receivers name: 'unnamed')
And I couldnot understand why this setDefault(true) method is also not working. Could you please suggest me a better answer.
Thanks & Regards,
Sarma.
Re: How to write the "Enter" event
When I have used setDefault(true) method, the "Forward" button has got the focus which was not there previously. Even then, it is not working when "Enter" key is pressed.
Thanks,
Sarma
Re: How to write the "Enter" event
Quote:
Originally Posted by Sarma
This is showing two errors as:
QObject::connect: (sender name: 'unnamed')
QObject::connect: (receivers name: 'unnamed')
Did you replace the variable names lineEdit and fwdButton with appropriate names you have used in your code?
Re: How to write the "Enter" event
In Qt3 pushbuttons don't have the "clicked" slot. You have to forward the signal (so instead of SLOT(clicked()) use SIGNAL(clicked()) ).
The setDefault() approach should work provided that your dialog inherits QDialog. Does it?
Re: How to write the "Enter" event
hello sir,
Thanks a lot once again. well thats working perfectly. Actually my application doesnot inherits QDialog. And one more thing sir, can we use
Code:
QObject::connect(sender,
SIGNAL(..
),receiver,
SIGNAL(...
));
I thought we should use a signal and a slot.Thats why i couldnot do it.
Thanks and Regards,
sarma.:)
Re: How to write the "Enter" event
Yes, it is possible to connect a signal directly to another signal. This will emit the second signal immediately whenever the first is emitted.