How to clear all items of QListView
Asked Answered
P

2

10

I searched a lot but I could not understand how to clear all items of QListView?

I used QStringListModel and QStringList to fill it.

Peaked answered 3/9, 2015 at 6:22 Comment(0)
V
18

You can either use model.setStringList( QStringList{} ), or manually delete the rows with model.removeRows( 0, model.rowCount() ).

Vanderpool answered 3/9, 2015 at 6:43 Comment(0)
T
3

This is working fine for me.

model1->removeRows( 0, model1->rowCount());

Thundering answered 17/8, 2021 at 10:39 Comment(1)
This answer, arriving just short of 6 years after the accepted answer, offers no useful information that isn't already provided in that answer.Wobbly

© 2022 - 2024 — McMap. All rights reserved.