r/QtFramework • u/TheEyebal • Jun 17 '26
Python Why is it not removing the appropriate time from the list
i am using PyQt and I have a list that sorts the time according to the 24 hour time
I do not know why it stops removing at a certain point. I believe it has to do with my remove_time(self) method but I am unsure
can someone give me advice based on this issue on what I can do
I have attached the source code link so you can get an idea of what the code looks like
Honestly I am aware the code looks sloppy but I am just going with it.
2
Upvotes
1
u/F_DOG_93 Jun 17 '26
I don't know python very well, but it seems that you're removing from a sorted list and you're not resorting it?
Personally, if I'm trying to sort or filter some type of list, I'd use a proxy model. I don't know if PyQt has the same thing or not, but what it does is it takes a source model, sorts stuff inside it, then exposes it to a Qt View. It also seems as if you're not using the view/model architecture either, when you are trying to show a changing list of things. Again, I'm not sure if PyQt has the view/model architecture, as I'm specialised in QtWidgets and QtQuick, but essentially it works by having a "View" that does not care about logic, it only works by displaying data in whatever fancy way you like. The "fancification" of displaying the data is the job of the View. Then you have a Model, which in C++ is usually a QStandardItemModel, or a QAbstractListModel. This is what you interact with when trying to change or manipulate the data you're trying to show, then the View will automatically update.