I use itemdelegate to create combobox for one column inside a treeview.
so when editing the cell, pressing UP/Down can change the value.
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 3.03.
These codes above works well for a normal qt application.
But it doesn't work in qtest framework
if I try to test it using qtest framework, the value of the cell always is 1.01
class MyTest: public QObject
{
Q_OBJECT
public:
...
void tst_combo_column();
...
private:
};
void MyTest::tst_combo_column()
{
...
treeview_->setCurrentIndex(idx_combo);
treeview_->edit(idx_combo);
QTest::keyClick(treeview_->focusWidget(), Qt::Key_Down);
QTest::keyClick(treeview_->focusWidget(), Qt::Key_Down);
QTest::keyClick(treeview_->focusWidget(), Qt::Key_Enter);
QVERIFY(GET_COL_VALUE("options") == "3.03"); //can not pass
}
I also tried mouseclick, but got the same issue.
My environment Qt5.5, ubuntu14.10