Results 1 to 3 of 3

Thread: QTest - Unable to pass Qt::Enter to QPushButton

  1. #1
    Join Date
    Dec 2010
    Posts
    9
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Maemo/MeeGo

    Default QTest - Unable to pass Qt::Enter to QPushButton

    I'm creating an automated test application using QTest Library. I'm able to simulate key presses on the application except when it gets to a window having QDialogButtonBox (Save, and Cancel). Here's my sample code:

    std::auto_ptr<MainForm> myForm( new MainForm( 3, 3 ));
    myForm->show();
    QTest::keyPress(myForm.get(), Qt::Key_0, NULL, 1000);
    QTest::keyRelease(myForm.get(), Qt::Key_0, NULL, 100);
    QWidget *pWin = QApplication::activeWindow();
    QCOMPARE(QString(pWin->objectName()), QString("MyMainForm"));

    now when it gets to the next window, it has several controls where the input focus is on a text edit control. When I press Enter, it presses the "Save" button. So theoretically, if I should pass Qt::Enter to the Form, it should press the "Save" button as well. However when I try to pass a keyPress:

    QTest::keyPress(pWin, Qt::Key_Enter, 1000);

    nothing happens... what do you think is going on? I've tried setFocus() to the button but nothing happens as well...

  2. #2
    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: QTest - Unable to pass Qt::Enter to QPushButton

    You probably want Qt::Key_Return and not Qt::Key_Enter.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2010
    Posts
    9
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Maemo/MeeGo

    Default Re: QTest - Unable to pass Qt::Enter to QPushButton

    Quote Originally Posted by wysota View Post
    You probably want Qt::Key_Return and not Qt::Key_Enter.
    I have already tried that... doesn't make a difference though...

Similar Threads

  1. Replies: 0
    Last Post: 22nd February 2010, 09:30
  2. Qtest
    By gollaan in forum Qt Programming
    Replies: 1
    Last Post: 17th December 2008, 09:04
  3. Replies: 1
    Last Post: 14th September 2008, 23:05
  4. QTest
    By LMZ in forum Qt Programming
    Replies: 5
    Last Post: 1st June 2007, 08:34
  5. Replies: 3
    Last Post: 26th September 2006, 12:16

Tags for this Thread

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.