View Full Version : mouseclick/keyclick not work for delegate widget inside view in QTest framework

18th July 2015, 05:00
I am trying to use QTest::keyClick to simulate key press for delegate item in a view.

But it seems I cannot simulate the operations below using qtest framework

QTest::keyClick(treeview_->focusWidget(), Qt::Key_Down);
QTest::keyClick(treeview_->focusWidget(), Qt::Key_Down);
QTest::keyClick(treeview_->focusWidget(), Qt::Key_Enter);

//after these code. the value of the cell should be 4.

These codes above works well, if I put them into a normal qt application.

But it doesn't work in qtest framework

I also tried mouseclick, but got the same issue.

My environment Qt5.5, ubuntu14.10

Attachment is the code to reproduce the issue. I made some changes base on the example of Qt5.5 : QT_DIR/Examples/Qt-5.5/widgets/itemviews/spinboxdelegate

1) after start spinboxdelegate, you can see that item(0,1) has changed to 4
2) running the test in "qt_test_not_work", it will fail.



18th July 2015, 05:57
Your test needs to call QApplication::processEvents() in order for the editor closure to be processed and the value to make it into the model.

18th July 2015, 12:20
It works now. Thanks!!