I don't see anything related to QGIS in your issue, you should probably ask on a Qt/PyQt mailing list.
On Fri, Feb 28, 2020 at 9:45 AM Jo <winfi...@gmail.com> wrote: > > Hi, > > I'm really stuck on this. > > I'm trying to test a combobox with a completer: > > When I do these manually, they work: > > cb = self.form.dockwidget.widget['sc_510_002'] > QTest.keyClicks(cb, '9000') > QTest.qWait(1000) > QTest.keyClick(cb, Qt.Key_PageUp, Qt.NoModifier, 500) > QTest.keyClick(cb, Qt.Key_Enter, Qt.NoModifier, 500) > > When I want to simulate them with the above commands, all I see is the popup. > > I also tried the following: > > cb = self.form.dockwidget.widget['sc_510_002'] > QTest.keyClicks(cb, '9000') > lv = cb.findChild(QListView) > QTest.qWait(1000) > QTest.mouseClick(lv.viewport(), Qt.LeftButton, 0, > lv.visualRect).center()) > > Based on what I found here: > > https://gist.github.com/peteristhegreat/cbd8eaa0e565d0b82dbfb5c7fdc61c8d > > and here: > > https://vicrucann.github.io/tutorials/qttest-signals-qtreewidget/ > > I was glad I managed to translate it from C, but no joy. > > Jo > > On Sat, Feb 22, 2020 at 10:55 AM Jo <winfi...@gmail.com> wrote: >> >> Hi, >> >> I would love to add some testing code to my ever more complex application. >> >> Somehow I'm not succeeding though, these are my attempts: >> >> #form.dockwidget.widget['sc_510_002'].setCurrentIndex(5) # , doing it >> directly doesn't work >> QTest.keyClicks(form.dockwidget.widget['sc_510_002'], '9000 Gent', >> Qt.NoModifier, 50) # this works, a popup appears >> QTest.keyClick(form.dockwidget.widget['sc_510_002'], Qt.Key_Enter, >> Qt.NoModifier, 500) >> QTest.keyClick(form.dockwidget.widget['sc_510_002'], Qt.Key_Tab, >> Qt.NoModifier, 500) >> #QTest.keyClick(form.dockwidget.widget['sc_510_002'].completer, Qt.Key_Down, >> Qt.NoModifier, 500) >> #print(dir(form.dockwidget.widget['sc_510_002'].completer().widget())) >> #form.dockwidget.widget['sc_510_002'].completer().setCurrentRow(0) >> #QTest.keyClick(form.dockwidget.widget['sc_510_002'].completer().widget().lineEdit(), >> Qt.Key_Enter, Qt.NoModifier, 500) >> #form.dockwidget.widget['sc_510_002'].setEditText('1000 Brussel') >> >> The popup is the completer, I suppose, so I also tried to send keystrokes to >> that, but no luck. >> >> This is the method I use to add the completer to the QComboBox: >> >> def add_completer(self, items): >> self.setEditable(True) >> self.setInsertPolicy(0) >> completer = QCompleter(items, self) >> completer.setFilterMode(Qt.MatchContains) >> completer.setCaseSensitivity(False) >> self.setCompleter(completer) >> self.setStyleSheet('QScrollBar: vertical {width: 16px;}') > > _______________________________________________ > QGIS-Developer mailing list > QGIS-Developer@lists.osgeo.org > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer -- Alessandro Pasotti w3: www.itopen.it _______________________________________________ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer