[Interest] QColumnView and QTreeView using same model

Michael Jackson mike.jackson at bluequartz.net
Wed May 4 15:43:37 CEST 2022


Thanks for the help. I was able to track it down to errors in my parent(…) method. I was just returning:

return createIndex(0, 0, some_unique_value);

which apparently works just fine for tree views but not for QColumnView.

Now on to figure out how to display checkboxes next to each item. I've tried:

Qt::ItemFlags ImportDataStructureModel::flags(const QModelIndex& index) const
{
  if(!index.isValid())
  {
    return {};
  }
  return Qt::ItemIsUserCheckable | Qt::ItemIsSelectable | QAbstractItemModel::flags(index);
}

Which does not seem to show anything. I'll probably have to create a custom delegate.
--
Mike Jackson


--
Michael Jackson | Owner, President
      BlueQuartz Software
[e] mike.jackson at bluequartz.net
[w] www.bluequartz.net


On 5/3/22, 6:07 PM, "Scott Bloom" <mailto:scott at towel42.com> wrote:

I have found when I use a custom model, most issues using views, are tied to an issue of some corner case condition in the model not being handled correctly. 



~~Scott



-------- Original message --------
From: Michael Jackson <mike.jackson at bluequartz.net> 
Date: 5/3/22 3:05 PM (GMT-08:00) 
To: Scott Bloom <scott at towel42.com>, Qt Interest List <interest at qt-project.org> 
Subject: Re: QColumnView and QTreeView using same model 

No idea that existed. Now just trying to figure out how to translate qmake instructions to modern CMake instructions to be able to link against it.
 
--
Mike Jackson
 
On 5/3/22, 4:41 PM, "Scott Bloom" <mailto:scott at towel42.com> wrote:
 
Have you run the modeltest on it?

Scott
 
From: Interest <interest-bounces at qt-project.org> On Behalf Of Michael Jackson
Sent: Tuesday, May 3, 2022 12:57 PM
To: Qt Interest List <interest at qt-project.org>
Subject: [Interest] QColumnView and QTreeView using same model
 
I have a custom QAbstractItemModel implementation that works correctly when using a QTreeView, i.e., I can open the complete hierarchy of the tree without any issues. I switched up to the QColumnView due to size constraints and now using the same exact instance of the model I can only navigate into the first item that has children. Other items at the root level that have children are shown with the little graphic arrow as having children but none of the children are actually listed in the next column over. I even put both the QTreeView and the QColumnView into my Widget at the same time with the same instance of the model and the QTreeView does not have any problems displaying the various levels.
 
Has anyone else seen something like this? I took at look at the Qt bug database and nothing really stuck out. I tried a QFileSystemModel for giggles and that worked as expected. So clearly I’ve got something sort of messed up in my custom model that allows the treeview to work but not the columnview. Odd.
--
Mike Jackson




More information about the Interest mailing list