Render QListView like QTableView
-
Hi guys
I dont really know how to call what i want. And because of that, i wasn't able to search for it properly.
I've got a simple list-model and i'm rendering it in a QListview. And that works fine. But is there a way to render a QListView like a Table?
Lets take 3 columns for example. That should look like that. (the number is the id from that data in the model)
How it looks like normaly:
[0]
[1]
[2]
[3]
....How i want it to look like:
[0] [1] [2]
[3] [4] [5]
....Ich hope you know what I mean?
dada
-
Hi and welcome
Have a look at the flow setting
http://doc.qt.io/qt-5.5/qlistview.html#flow-propSetting it to LeftToRight might do what you want :)
Also set isWrapping to true
Also look at gridsize. -
Nope, doesn't work. It changes it from:
[0]
[1]
[2]
[3]
...to:
[0] [1] [2] [3] [4] .....Howerver, if there's no easy way i'll use a QTableView and change the data-method in the model to act like an table but with an 1D array. Like that: (I use Qt only in Python, so i'm showing you python)
return data[(row - 1) * 3 + column]
I think that should work
But thank you anyway
-
well it will wrap at widgets border
so if u need it to wrap before, u might try icon mode/grid mode.
http://stackoverflow.com/questions/11379816/qlistview-in-gridmode-auto-stretch-with-fixed-items-on-a-row-columnWell using QTableView does seems like a better fit then.
-
Hi
Oh you need something like[0] [1] [2]
[x]
[4] [5] [x]
[x]is empty ? -
Nope. I need what you postet^^
But before your post, i tried to archive my goal with an QTableView. But there occured some issues when your datamodel hasn't enaugh items to fill the last row completly. You know what i mean?
But it doesnt care anymore. Your solution works fine.