PyQt - Trouble extracting different pieces of data from the same model

37 views
Skip to first unread message

Daniel Springall

unread,
Sep 25, 2017, 8:06:53 AM9/25/17
to Python Programming for Autodesk Maya

I have recently created an asset browser inside of Maya using Maya’s built in UI toolsets. I’m currently in the process of converting this interface to PyQt partly because I want to give the user more control over how the data can be accessed/manipulated, but also just as a nice project I can sink my teeth into and learn PyQt with.

I currently have a model (QAbstractTableModel) that is populated by my Maya assets (QStandardItem). Each item holds different pieces of information about the asset such as, name, type, filePath, hasX, hasY…. So on. I have successfully been able to make a QTableView where each row is an item in the model and each column is some data from the item, so column 1 returns item.name and column 2 returns item.type, etc.

I am now trying, and failing, to create a second view pointing at the same model, in this instance some sort of list view with a flow layout, that will be populated with the thumbnails for each item. This way I can toggle between views and maintain item selection/filtering between them.

I was able to create a window that had a flowLayout and I then populated it by iterating over the items in my data set and for each item generated a QWidget that housed the icon as well as a label for the name of the item. But this wasn’t (unless I am miss-understanding PyQt) pointing at my model to make it so that if I updated my model or used a QFilterProxyModel the windows/widgets wouldn’t stay in sync.


As I am relatively new to PyQt I’m not sure if I’m just using the wrong tool for the job, or completely missing something… Any help or insight is greatly appreciated.


Thanks,

Daniel

Justin Israel

unread,
Sep 25, 2017, 8:53:50 PM9/25/17
to python_in...@googlegroups.com
On Tue, Sep 26, 2017 at 1:06 AM Daniel Springall <daniel.sp...@gmail.com> wrote:

I am now trying, and failing, to create a second view pointing at the same model, in this instance some sort of list view with a flow layout, that will be populated with the thumbnails for each item. This way I can toggle between views and maintain item selection/filtering between them.

I was able to create a window that had a flowLayout and I then populated it by iterating over the items in my data set and for each item generated a QWidget that housed the icon as well as a label for the name of the item. But this wasn’t (unless I am miss-understanding PyQt) pointing at my model to make it so that if I updated my model or used a QFilterProxyModel the windows/widgets wouldn’t stay in sync.


Is it your goal to create the new custom view yourself, or are you just looking for a solution to this? Have you tried using a QListView that is set to a left-to-right flow mode, and icon mode? That sounds like what you are after. Otherwise you would need to subclass QAbstractItemView and implement the right methods in order to draw or layout your items according to what the model is telling you.
 


As I am relatively new to PyQt I’m not sure if I’m just using the wrong tool for the job, or completely missing something… Any help or insight is greatly appreciated.


Thanks,

Daniel

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b9a18cac-728a-4b4c-81fd-e5e80bae34b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages