Results 1 to 15 of 15

Thread: Posting a QKeyEvent to a QLineEdit

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: Posting a QKeyEvent to a QLineEdit

    Looks like it might be impossible to handle it this way. Still if you send a focus event and the widget even receives it, QApplication won't be tricked. Although the widget prepares itself as if it had been focused (like QLineEdit's cursor starts blinking etc.), the next (real) key press event still goes to a widget which the qApp believes that has focus. QApplication updates it's focus widget (QApplicationPrivate::setFocusWidget()) only when a focus event comes from the underlying system, window manager, or focus is set manually by calling QWidget::setFocus().
    J-P Nurmi

  2. The following user says thank you to jpn for this useful post:

    cocheci (5th June 2006)

  3. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Posting a QKeyEvent to a QLineEdit

    Maybe you could use QtTest module? It has some methods for sending key events.

  4. The following user says thank you to jacek for this useful post:

    cocheci (5th June 2006)

  5. #3
    Join Date
    May 2006
    Posts
    16
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Posting a QKeyEvent to a QLineEdit

    Quote Originally Posted by jacek
    Maybe you could use QtTest module? It has some methods for sending key events.
    Thanks Jacek, it looks like this might work, I'll definitely try it. Here's the first phrase from the "Simulating GUI Event" chapter:

    QTestLib features some mechanisms to test graphical user interfaces. Instead of simulating native window system events, QTestLib sends internal Qt events. That means there are no side-effects on the machine the tests are running on.

    If this works, I'll let you know.

    Cristian

  6. #4
    Join Date
    May 2006
    Posts
    16
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Posting a QKeyEvent to a QLineEdit

    Quote Originally Posted by cocheci
    Thanks Jacek, it looks like this might work, I'll definitely try it. Here's the first phrase from the "Simulating GUI Event" chapter:

    QTestLib features some mechanisms to test graphical user interfaces. Instead of simulating native window system events, QTestLib sends internal Qt events. That means there are no side-effects on the machine the tests are running on.

    If this works, I'll let you know.

    Cristian
    This worked, thank you all!!

    Cristian

Similar Threads

  1. a box around QLineEdit?
    By GreyGeek in forum Qt Tools
    Replies: 13
    Last Post: 8th February 2006, 15:40

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
  •  
Qt is a trademark of The Qt Company.