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. Problem with QStyledItemDelegate and QSortFilterProxyModel
Qt 6.11 is out! See what's new in the release blog

Problem with QStyledItemDelegate and QSortFilterProxyModel

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.1k 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by
    #1

    I have a table model based on a QAbstractTableModel.

    I use a subclass of QStyledItemDelegate to handle display of one of the columns

    Up until now I didn't have sort capability, so I interposed a QSortFilterProxyModel
    between the table model and the table view:

    	//
    	// Set up a QSortFilterProxyModel to allow sorting of the table view
    	// (it sits between the actual model and the view to provide sorting
    	// capabilty)
    	//
    	proxyModel = std::make_unique<QSortFilterProxyModel>(this);
    	proxyModel->setSourceModel(frameList.currentTableModel());
    
    	ui->tableView->setModel(proxyModel.get());
    	ui->tableView->setSortingEnabled(true);
    

    net result the styled item delegate blew up on the Q_ASSERT in the following code that checks the cell attributes are correct:

    	constexpr uint neededFeatures
    	{ static_cast<uint>(QStyleOptionViewItem::HasCheckIndicator |
    		QStyleOptionViewItem::HasDisplay |
    		QStyleOptionViewItem::HasDecoration) };
    
    	Q_ASSERT(neededFeatures == (opt.features & neededFeatures));
    

    Shouldn't the sort filter proxy model pass that sort of stuff through?

    David

    Christian EhrlicherC 1 Reply Last reply
    0
    • PerdrixP Perdrix

      Problem found in my code :(

      D.

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #5

      @Perdrix Nice to hear, can you mark the topic as solved then?

      Normally a SFPM does not change the data until you derive from it and change it somewhere by your own.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • PerdrixP Perdrix

        I have a table model based on a QAbstractTableModel.

        I use a subclass of QStyledItemDelegate to handle display of one of the columns

        Up until now I didn't have sort capability, so I interposed a QSortFilterProxyModel
        between the table model and the table view:

        	//
        	// Set up a QSortFilterProxyModel to allow sorting of the table view
        	// (it sits between the actual model and the view to provide sorting
        	// capabilty)
        	//
        	proxyModel = std::make_unique<QSortFilterProxyModel>(this);
        	proxyModel->setSourceModel(frameList.currentTableModel());
        
        	ui->tableView->setModel(proxyModel.get());
        	ui->tableView->setSortingEnabled(true);
        

        net result the styled item delegate blew up on the Q_ASSERT in the following code that checks the cell attributes are correct:

        	constexpr uint neededFeatures
        	{ static_cast<uint>(QStyleOptionViewItem::HasCheckIndicator |
        		QStyleOptionViewItem::HasDisplay |
        		QStyleOptionViewItem::HasDecoration) };
        
        	Q_ASSERT(neededFeatures == (opt.features & neededFeatures));
        

        Shouldn't the sort filter proxy model pass that sort of stuff through?

        David

        Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @Perdrix said in Problem with QStyledItemDelegate and QSortFilterProxyModel:

        Shouldn't the sort filter proxy model pass that sort of stuff through?

        Yes, please show a minimal, compilable example of your code

        proxyModel = std::make_unique<QSortFilterProxyModel>(this);

        Happy crashings

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        PerdrixP 1 Reply Last reply
        0
        • Christian EhrlicherC Christian Ehrlicher

          @Perdrix said in Problem with QStyledItemDelegate and QSortFilterProxyModel:

          Shouldn't the sort filter proxy model pass that sort of stuff through?

          Yes, please show a minimal, compilable example of your code

          proxyModel = std::make_unique<QSortFilterProxyModel>(this);

          Happy crashings

          PerdrixP Offline
          PerdrixP Offline
          Perdrix
          wrote on last edited by
          #3
          This post is deleted!
          1 Reply Last reply
          0
          • PerdrixP Offline
            PerdrixP Offline
            Perdrix
            wrote on last edited by
            #4

            Problem found in my code :(

            D.

            Christian EhrlicherC 1 Reply Last reply
            0
            • PerdrixP Perdrix

              Problem found in my code :(

              D.

              Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #5

              @Perdrix Nice to hear, can you mark the topic as solved then?

              Normally a SFPM does not change the data until you derive from it and change it somewhere by your own.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              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