c++ - QTest - Unable to pass Qt::Enter to QPushButton -
i'm creating automated test application using qtest library. i'm able simulate key presses on application except when gets window having qdialogbuttonbox (save, , cancel). here's 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 gets next window, has several controls input focus on text edit control. when press enter, presses "save" button. theoretically, if should pass qt::enter form, should press "save" button well. when try pass keypress:
qtest::keypress(pwin, qt::key_enter, 1000);
nothing happens... think going on? i've tried setfocus() button nothing happens well...
in qdialogbuttonbox may needed button with
qpushbutton * qdialogbuttonbox::button ( standardbutton )
and call it's setfocus method. if can't access qdialogbuttonbox directly, may with
qlist<t> qobject::findchildren ( const qstring & name = qstring() )
or buttons themself method...
Comments
Post a Comment