Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt - C++ - QListView - Custom Shape



  • I'm trying to create a QListView with a polygon shape. Or in other words, I would like that my list will look something like this:

    enter image description here

    which at this moment looks like this:

    enter image description here

    WHAT I KNOW or TRYED ALREADY:

    • I know about the paintEvent(QPaintEvent *e) function where I can change the shape of a widget, but I don't know how can I change the shape of the actual box which contains the items of that list.
    • I've also tried already with QStyledItemDelegate and I've overridden the 2 functions paint and sizeHint. But with those, I can only change the elements within the list, not the actual list shape.

    In other words, the first option with paintEvent it's going to change my shape of the widget(the BLACK part from the image), not the container which holds the elements. The second option it's going to change just looks of elements from the list, not the container which holds them.

    In short, is there any way in which I can change the shape of that container?


  • Lifetime Qt Champion

    Hi,

    One thing worth trying is the Qt Graphics View Framework. You might be able to apply the transforms you want on the item but I can't guarantee it.


Log in to reply