Using a QCompleter in a QTableView with Qt and Python -


I'm reading, and it looks very straightforward.

But how can I set up an editable cell to use QCompleter? Do I have to tell it to QTableView to use the QLineEdit widget in any way? How can I do this?


Edit: Hmm, I think there is something with it, but I do not know anything about it or how to use them. In


Edit: I like to try to solve the RobbieE, is something that works, but it is the geometry of the wrong popup combo box and dragon crashes when I press Enter < / p>

  class CompleterDelegate (QtGui.QStyledItemDelegate) .: def __init __ (self, parent = none, CompleterSetupFunction = no): Super (CompleterDelegate, self) .__ init __ (parent) self .completerSetupFunction = completerSetupFunction def createEditor (auto, parent, option, index): Return QtGui.QLineEdit (parent) def setE ditorData (Self, Editor, Index): Super (CompleterDelegate, self) .setEditorData (Editor, Index) self._completerSetupFunction (Editor, Index)   

I _completerSetupFunction looks like this:

  def setupFunc (editor, index): Completer = MyCompleter (editor) completer.setCompletionColumn (0) completer.setCompletionRole (QtCore.Qt.DisplayRole) completer.setCase sensitivity (QtCore.Qt.CaseInsensitive) editor .setCompleter (Completer) completer.setModel (myAbstractItemModel)    

Create a Sbclas

You can only copy the setEditorData function To Urthy, check that the editor widget QLineEdit and then set integer.

Please, I know that I do not know the dragon but how it will be done in C ++. Hopefully, translations in Python will be easy

  class MyDelegate: public QStyledItemDelegate {public:. Zero setEditorData (QWidget * editor, call QModelIndex constant & amp; Index) {// so superclass' function editor widget receives the data QStyledItemDelegate :: setEditorData (editor, index); // Check that the editor has passed a QLineEdit QLineEdit * lineEdit = qobject_cast & lt; QLineEdit & gt; (Editor); If (lineEdit! = 0) {// whatever is required to be completed, to ensure that the editor is parent QObject, so it was removed with the editor line Edit.setComplete (new MyCompleter (editor)) goes; }}};    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -