Can't find related code for "QT Widgets: List Widget "

Hello there!

I’m trying to tweek the UI of the tk-shotgun-launchpublish application, which is using the QT Widgets Framework.

What i am searching for is the “List Widget” seen in the first picture of this Doc ( https://support.shotgunsoftware.com/hc/en-us/articles/219040018-QT-Widgets ) , because that’s the one i want to change.

Unfortunately until now i couldn’t find the related file/ code snippet inside the qtwidgets app.
Is there something i am not understanding correctly?

Thanks for your help in advance
Jonas!

3 Likes

Hi Jonas, Welcome to the forums!!

I think the tk-framework-qtwidgets reference doc should help you understand how to use the qtwidgets framework within the app.

Also we have a Widget demos app that include examples of how to use these:


You can add that to your config and play around with them.

I think this is what you are looking for specifically however:
https://developer.shotgunsoftware.com/tk-framework-qtwidgets/views.html?highlight=views

The loader in the screen shot uses a standard QListView and then uses the Shotgun model and delegate to apply the content and style.

Hopefully, that can get you started? Qt views, models and delegates can be a bit confusing to get your head around if you’ve not used them before.
Cheers
Phil

3 Likes

Oh also this is the Qt docs on views/models as well: https://doc.qt.io/qt-5/model-view-programming.html

3 Likes

Hey Philip.
Thank you very much for the given answer.
My confusion came up by simply looking into the wrong app in the first place.
Now that I started working on the real thing, I ran into another problem:

My idea is to dynamically resize the single publishes in the history view so that the description text is always fully readable.
For that I tried to change the sizeHint() function inside the SgPublishHistoryDelegate class.

My experimental code looks like this:

def sizeHint(self, style_options, model_index):
    sg_item = shotgun_model.get_sg_data(model_index)
    desc_str = sg.item.get("description") or "No Description Given"
    text_length = len(desc_str)
    return QtCore.QSize( 200 , max( (text_length / 39) * 24,  100))

I noticed, that the model_index is always pointing to the same entry and therefore the description string is always the one of the first entry. As one would expect, the result is that every entry gets the height that only the first one should get.

So I bet there’s something about this whole process I don’t realy understand yet and couldn’t manage to find out myself till now despite reading the links philip gave me. Could someone help me with this?

Thanks again in advance!
Jonas

Edit: I think the problem is, that QList Items arent variable in their size. Is there a known workaround for this working with the shotgun api?

2 Likes

Found the solution! For anyone who’s interested:

The line of code responsible for the behaviour descriped above was line 225 in the /ui/dialog.py

        self.publish_view.setUniformItemSizes(True)
1 Like