hasu
8th January 2013, 16:32
Hi Guys,
I'm planning on writing a small application/game launcher, just like Steam perhaps but with support for all kinds of games and applications.
Now, all the links are stored as objects subclassed from QListWidgetItem in a QListWidget in viewMode == IconView.
While dragging those around in the widget works just fine, I can't find a way to explicitly set a QListWidgetItem's location in a QListWidget in code.
This becomes important when restoring a profile or maybe suppressing reordering of the ListWidget after resizing.
I am able to determine an item's (row,column) coordinates in the grid, maybe a bit cumbersome, with the following code fragment (please note I use PyQt, but this should be readable I guess):
r = self.visualItemRect(item)
newpos = [ r.top()/self.gridSize().height(), r.left()/self.gridSize().width()) ]
So while I am able to save an item's position to a profile when exiting the program, I fail to see a possibility to restore such a setup when reloading the profile.
I'm looking for a kind of QListWidget::setItemPosition( QListWidgetItem* item, int x, int y ).
Is there anything I can use, or do I have to switch to complete Model/View-style programming instead of subclassing QListWidget and QListWidgetItem?
Honestly, I feel completely overwhelmed when reading the related documentation.
I'll attach a screenshot to hopefully clarify my problem, I want to be able to arrange these icons freely just like, for example, on desktop.
8567
Thanks for your help, and yikes, my first post here. :)
I'm planning on writing a small application/game launcher, just like Steam perhaps but with support for all kinds of games and applications.
Now, all the links are stored as objects subclassed from QListWidgetItem in a QListWidget in viewMode == IconView.
While dragging those around in the widget works just fine, I can't find a way to explicitly set a QListWidgetItem's location in a QListWidget in code.
This becomes important when restoring a profile or maybe suppressing reordering of the ListWidget after resizing.
I am able to determine an item's (row,column) coordinates in the grid, maybe a bit cumbersome, with the following code fragment (please note I use PyQt, but this should be readable I guess):
r = self.visualItemRect(item)
newpos = [ r.top()/self.gridSize().height(), r.left()/self.gridSize().width()) ]
So while I am able to save an item's position to a profile when exiting the program, I fail to see a possibility to restore such a setup when reloading the profile.
I'm looking for a kind of QListWidget::setItemPosition( QListWidgetItem* item, int x, int y ).
Is there anything I can use, or do I have to switch to complete Model/View-style programming instead of subclassing QListWidget and QListWidgetItem?
Honestly, I feel completely overwhelmed when reading the related documentation.
I'll attach a screenshot to hopefully clarify my problem, I want to be able to arrange these icons freely just like, for example, on desktop.
8567
Thanks for your help, and yikes, my first post here. :)