Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QComboBox with QSortFilterProxyModel as a model.

QComboBox with QSortFilterProxyModel as a model.

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.5k Views 1 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.
  • B Offline
    B Offline
    bsomervi
    wrote on last edited by
    #1

    Hi,

    I have several custom models which I wrap with QSortFilterProxyModel to save me having to implement ordering constraints in my models. All I have to do is issue a sort key in their data() method under a custom user role. This is great and a big time saver since I don't have to do any of the persistent model index accounting involved with "editable and sortable" custom models. I want to use a column of these models as a model in a QComboBox (think choosing a foreign key value in database terminology).

    My problem is that neither QComboBox nor it's internal view class seem to respond to the model signals that are issued by QSortFilterProxyModel when it sorts the proxy. I'm sure I'm missing something obvious since the QComboBox responds to row/column adds and removes but I can't find out how to make it respond to row/column moves and layout change signals.

    If I sort the proxy model column manually by calling sort before setting the QComboBox model everything is fine until the proxy changed elsewhere, the sort order breaks down in the QComboBox popup list.

    I've tried turning off dynamic sorting and filtering and calling sort() on the proxy model myself when it gets changed, that works fine with other views of it like QTableView but the QComboBox popup list reverts to some seemingly random ordering.

    Is this a deficiency in QComboBox?

    TIA
    Bill.

    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