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
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer