0
votes

I'm working on a grid for project and GridView does ALMOST exactly what I need with the exception of the following:

  • I'd like to not inherit from Flickable and implement my own scrolling behavior manually
  • I'd like to have the option to add spacing between grid cells.

Is there anyway I can view and edit the actual QML or C++ implementation of the QML GridView type (or even better, QtQuick types in general) so I can learn from it and make the changes to it that suit my needs? This is something that I have repeatedly found myself wanting to do while working with QML. This is just one example.

1

1 Answers

1
votes

You can see the source code for GridView here:

https://github.com/qt/qtdeclarative/blob/5.15.2/src/quick/items/qquickgridview.cpp

If you build Qt from source, you can locate that same file in the source tree, make edits to it and recompile.

You may also be able to subclass it and override some of its behavior (though Qt makes that hard by design). You could also copy the code for it into your own project, rename it and make it a project-specific implementation class.

However, I would recommend avoiding that. For instance, you can easily add space between grid cells in a GridView by placing your grid content inside of an Item that has some margin between it and your content.

Also, ScrollBar can be used with Flickable and provides a bit of control over its scrolling behavior.