Results 1 to 11 of 11

Thread: How to write the "Enter" event

  1. #1
    Join Date
    Mar 2006
    Location
    Hyderabad
    Posts
    69
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default 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.
    Attached Images Attached Images

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to write the "Enter" event

    Qt Code:
    1. connect(lineEdit, SIGNAL(returnPressed()), fwdButton, SIGNAL(clicked()));
    To copy to clipboard, switch view to plain text mode 

    [EDIT] Changed SLOT->SIGNAL, thanks wysota for pointing this out
    Last edited by jpn; 24th March 2006 at 13:12.

  3. #3
    Join Date
    Mar 2006
    Posts
    19
    Thanks
    1

    Default Re: How to write the "Enter" event

    hi sarma,

    could u resend the screenshot again...i guess it didnt get attached

    Cheers,
    Amulya

  4. #4
    Join Date
    Mar 2006
    Posts
    19
    Thanks
    1

    Default Re: How to write the "Enter" event

    sorry...disregard my above post

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to write the "Enter" event

    Set "Forward" as the default button (setDefault(true) on the button).

  6. #6
    Join Date
    Mar 2006
    Location
    Hyderabad
    Posts
    69
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default 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:
    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.

  7. #7
    Join Date
    Mar 2006
    Location
    Hyderabad
    Posts
    69
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default 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

  8. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default 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?

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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?

  10. #10
    Join Date
    Mar 2006
    Location
    Hyderabad
    Posts
    69
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default 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
    Qt Code:
    1. QObject::connect(sender,SIGNAL(..),receiver,SIGNAL(...));
    To copy to clipboard, switch view to plain text mode 

    I thought we should use a signal and a slot.Thats why i couldnot do it.

    Thanks and Regards,
    sarma.

  11. #11
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default 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.

Similar Threads

  1. Replies: 4
    Last Post: 19th February 2009, 11:10
  2. Custom event gets not propagated to the top level widget
    By nightghost in forum Qt Programming
    Replies: 0
    Last Post: 29th January 2009, 09:06
  3. Event propagation direction
    By spraff in forum Qt Programming
    Replies: 0
    Last Post: 6th December 2008, 21:03
  4. Qt event queue overloading?
    By gct in forum Qt Programming
    Replies: 3
    Last Post: 17th March 2008, 18:39
  5. Workload in a QThread blocks main application's event loop ?
    By 0xBulbizarre in forum Qt Programming
    Replies: 14
    Last Post: 9th April 2006, 21:55

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.