qt - mouseclick/keyclick not work for delegate widget inside treeview in QTest framework -


i use itemdelegate create combobox 1 column inside treeview.

so when editing cell, pressing up/down can change value.

enter image description here

but seems cannot simulate 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. value of cell should 3.03. 

these codes above works normal qt application.

but doesn't work in qtest framework

if try test using qtest framework, value of cell 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 tried mouseclick, got same issue.

my environment qt5.5, ubuntu14.10

you can use qapplication::focuswindow() target qtest::keyclick() calls.

for example, test case tests item delegate returns editors autocompletion:

// application has main window, main widget // tree view auto v = qapplication::focuswindow(); // go specific row qtest::keyclick(v, qt::key_down,  qt::nomodifier, 10); qtest::keyclick(v, qt::key_down,  qt::nomodifier, 10); // start editing qtest::keyclick(v, qt::key_f2,    qt::nomodifier, 10); // nullptr, qtest own focus // dependent window/widget selection // focuswindow() doesn't work here keyclicks() qtest::keyclicks(nullptr, "rec",  qt::nomodifier, 10); // navigate completion list popup qtest::keyclick(v, qt::key_down,  qt::nomodifier, 10); qtest::keyclick(v, qt::key_down,  qt::nomodifier, 10); // select completion , finish editing qtest::keyclick(v, qt::key_enter, qt::nomodifier, 10); qtest::keyclick(v, qt::key_enter, qt::nomodifier, 10); // verify change stored in model ... 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -