Search code examples
qtqwidgetqcompleter

QCompleter popup position


I'm having trouble trying to move the QCompleter popup view position.

I tried the QCompeter:complete and it's pops the completer view in the position as I wanted. But if I start typing it close it, and open the completer in the 'default' position.

I also tried the QCompleter:setPopup() function. I create a QListView and I tried to moved to different position. And still the QCompleter popup view remains in the same position.

In my project I'm using a QFrame that wrap QLineEdit. And I want that the completer view will get the QFrame position. I succeed to set the completer view width via setFixedWidth() function. but not to move the position.

Any suggestions ?

Thanks.


Solution

  • I suggest setting the CompletionMode to InlineCompletion, so there will be no popup. Then make your QListView indepedant of the QLineEdit; just react to signals that indicate when a view types some text, leaves the QLineEdit, etc (hint: subclass QListView) and sets the text in QLineEdit when a user selects a value from the list.

    I think it will be difficult to override the placement since QCompleter takes ownership of your QListView. (Personally I think it does not make much sense to place the completion list somewhere else than next to the input field, but alas...)