Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Combobox completer popup is locked out in modal dialog
Forum Updated to NodeBB v4.3 + New Features

Combobox completer popup is locked out in modal dialog

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 228 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Neil Johnson
    wrote on last edited by
    #1

    I am trying to use a filtering combobox which filters the list of combo entries based on user input to the line edit. All works as expected except if the dialog is modal, the user can not interact with the popup list to select an item. It seems the popup is not part of the dialog and hence disabled. If I run the dialog as non modal (dlg.show() instead of dlg.exec()) everything works.

    What am I missing. filtering combobox code is below.

    from PyQt5.QtCore import *
    from PyQt5.QtGui import *
    from PyQt5.QtWidgets import *
    class FilteringComboBox(QComboBox):
    def init(self, parent=None, **kwargs):
    QComboBox.init(self, parent, editable=True, focusPolicy=Qt.StrongFocus, **kwargs)

        self._proxy=QSortFilterProxyModel(self, filterCaseSensitivity=Qt.CaseInsensitive)
        self._proxy.setSourceModel(self.model())
    
        self._completer=QCompleter(
            self._proxy,
            self,
            activated=self.onCompleterActivated
        )
        self._completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion)
        self.setCompleter(self._completer)
    
        self.lineEdit().textEdited.connect(self._proxy.setFilterFixedString)
        self.currentIndexChanged.connect(self.onCurrentIndexChanged)
    
    @pyqtSlot(int)
    def onCurrentIndexChanged(self, data):
        print("changed to index: {}, value: {}, code: {}".format(data, self.itemText(data), self.currentData(role=Qt.UserRole+1)))
        
        
    @pyqtSlot(str)
    def onCompleterActivated(self, text):
        if not text: return
        self.setCurrentIndex(self.findText(text))
        self.activated[str].emit(self.currentText())
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Isn't that what QCompleter already does ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved