QListWidget expand height dynamically
-
wrote on 5 Aug 2023, 12:13 last edited by
Hello, I want to make the design below in qt. I have a few questions.
1. question
In this design, the mouse can be scrolled and scrolled down almost infinitely. I want to do this too but if I use QListWidget for the list in category "All Games" this qlistwidget doesn't expand. (Picture 2) (Scrollbar is visible in the bottom qlistwidget, it should not be visible and the height of the qlistwidget should expand dynamically )
If I prefer QHBoxlayout instead of QListWidget I can get the look I want, but I want to use qlistwidget for ease of use.
Code for QListWidget:
item = QListWidgetItem() kart_oyun = GameWidget(mydata, item=item, liste=self.ui.listGames) # my custom widget item.setSizeHint(kart_oyun.size()) myqlistwidget.addItem(item) myqlistwidget.setItemWidget(item, kart_oyun)
Code for layout:
kart_oyun = GameWidget(mydata, item=item, liste=self.ui.listGames) # my custom widget self.layGames.addWidget(kart_oyun)
2. question
I added animation when hovering over my custom widget (card) and the card expands, but sometimes when it doesn't fit, it goes to the bottom line and becomes unreadable (video is also clearer)VIDEO: STREAMABLE
-
-
Hello, I want to make the design below in qt. I have a few questions.
1. question
In this design, the mouse can be scrolled and scrolled down almost infinitely. I want to do this too but if I use QListWidget for the list in category "All Games" this qlistwidget doesn't expand. (Picture 2) (Scrollbar is visible in the bottom qlistwidget, it should not be visible and the height of the qlistwidget should expand dynamically )
If I prefer QHBoxlayout instead of QListWidget I can get the look I want, but I want to use qlistwidget for ease of use.
Code for QListWidget:
item = QListWidgetItem() kart_oyun = GameWidget(mydata, item=item, liste=self.ui.listGames) # my custom widget item.setSizeHint(kart_oyun.size()) myqlistwidget.addItem(item) myqlistwidget.setItemWidget(item, kart_oyun)
Code for layout:
kart_oyun = GameWidget(mydata, item=item, liste=self.ui.listGames) # my custom widget self.layGames.addWidget(kart_oyun)
2. question
I added animation when hovering over my custom widget (card) and the card expands, but sometimes when it doesn't fit, it goes to the bottom line and becomes unreadable (video is also clearer)VIDEO: STREAMABLE
wrote on 5 Aug 2023, 20:47 last edited by@Emrecp, about your first question - I think it isn't about
QListWidget
itself but more about about data model underneath it. ProbablyfetchMore()
andcanFetchMore()
methods ofQAbstractItemModel
are what you are looking for. -
@Emrecp, about your first question - I think it isn't about
QListWidget
itself but more about about data model underneath it. ProbablyfetchMore()
andcanFetchMore()
methods ofQAbstractItemModel
are what you are looking for.wrote on 6 Aug 2023, 17:17 last edited by@StarterKit First of all thank you very much for your reply. Can you write a short sample code?
-
@StarterKit First of all thank you very much for your reply. Can you write a short sample code?
wrote on 7 Aug 2023, 09:24 last edited by@Emrecp, I don't think my code would be any better then "an official one".
So I would propose you to review a Fetch More Example
4/4