Lorenzo CastellinoPost it as a pastebin or it will make people mad 😂
# ------------------------------------------------ My custom widget item
class SMSoftwareCustomItem(QListWidgetItem):
def init(self, software_id, software, version, version_number, logo, parent_list_widget=None):
super().init()
# Create the custom widget and load the UI
self.widget = QWidget()
self.ui = SMSoftwareAddFrame()
self.ui.setupUi(self.widget)
self.software_name = str(software)
self.software_id = software_id
self.version = version
self.version_number = version_number
self.logo = logo
self.ui.label_20.setText(str(software))
self.ui.label_21.setText(str(version_number))
self.ui.label_22.setText(QCoreApplication.translate("Frame", "latest version" if str(version) == "1" else "", None))
# --------------------------- function to move every item from one list to another
def sm_move_all_right(self):
"""Moves all items from left list to right list."""
left_list = self.new_window.smLeftListWidget
right_list = self.new_window.smRightListWidget
while left_list.count() > 0:
# Take the first item from the left list
item = left_list.item(0)
widget = left_list.itemWidget(item)
if widget:
# Extract data from the custom widget
software_id = item.software_id # Example: software ID
software_name = item.software_name # Example: software ID
version = item.version # Example: software ID
version_number = item.version_number # Example: software ID
logo = item.logo # Example: software ID
# Create a new custom item and add it to the right list
new_item = SMSoftwareCustomItem(software_id, software_name, version , version_number,logo )
right_list.addItem(new_item)
right_list.setItemWidget(new_item, new_item.widget)
monkey.D.Dragon# ------------------------------------------------ My custom widget item
class SMSoftwareCustomItem(QListWidgetItem):
def init(self, software_id, software, version, version_number, logo, parent_list_widget=None):
super().init()
# Create the custom widget and load the UI
First, please paste the code at pastebin.com or something like that and provide a link. This will save the formatting. But more importantly, the chat is bridged to an IRC. There, every line is a message, making it painstaking to collect the code to execute.
Second, the code is far from an MWE, with lots of non-essential items. There is no entry point, there is no new_window. I suspect that deleting the widget manually might not be necessary in Python, but I'm too lazy to make the test up.
Anton YablokovFirst, please paste the code at pastebin.com or something like that and provide a link. This will save the formatting. But more importantly, the chat is bridged to an IRC. There, every line is a message, making it painstaking to collect the code to execute.
Second, the code is far from an MWE, with
above is just for refrence , i wont be able to give the whole source code . I have provided with the code that is being executed and the only error or msg in the terminal after app crashes.
I am unable to open any pasting site in my ofc pc due to antivirus stops it from pasting , sorry for the inconvenience
new_window is just refrence to the ui , like self.ui.abc
I can explain any of it but all i could share is above , there is no such error you will find in it as i have done it multiple times . only logically we can argue that it can be reason that before the any item was deleted from one list I have fired he function to move it another list and so
monkey.D.Dragonabove is just for refrence , i wont be able to give the whole source code . I have provided with the code that is being executed and the only error or msg in the terminal after app crashes.
I am unable to open any pasting site in my ofc pc due to antivirus stops it from pasting , sorry for the inc
See if you can chop down your app to something much smaller, but still reproduces the problem.
I realize that isn't always so easy, but it's really the best way to get others whom are willing to help you.
Keith KyzivatSee if you can chop down your app to something much smaller, but still reproduces the problem.
I realize that isn't always so easy, but it's really the best way to get others whom are willing to help you.
I understand that mate . But it won't be possible as I won't be going office for a few days so sorry for that.
Every week, in the Dev Notes, I read that the packages are too heavy. Would it be better to split the packages into separate classes or groups of a few ones?
I mean, release PySide6_QtCore with QtCore only. Then, release PySide6_QtGui with QtGui only. Such a package would depend on PySide6_QtCore, thus working fine, just like now. If QtCore and QtGui cover all the needs, a person wouldn't install other packages, therefore keeping the Python environment (and the deployment build) small.
For the devs, there is more work, but this approach would make the packages at PyPI smaller individually. As a side effect, if an issue occurs, it would require refreshing only a small package, independently on the rest of PySide6 or even PySide6_Essentials.
And as for QtWidgets, I never use even half of them. Still, I have to carry all the code along. Alright, it's not that much. But the PDF parts? QML? Are they that inseparable from the rest?
from PySide6.QtWidgets import QApplication, QListView
from PySide6.QtCore import QAbstractListModel, QModelIndex, Qt
import sys
import typing
class ChoiceModel(QAbstractListModel):
def __init__(self, data: typing.List[dict]) -> None:
super().__init__()
self._data = data
def rowCount(self, parent: QModelIndex = QModelIndex()) -> int:
if parent == QModelIndex():
return len(self._data)
return 0
def data(self, index: QModelIndex, role: int = Qt.DisplayRole) -> typing.Any:
if not index.isValid():
return None
if role == Qt.DisplayRole:
return self._data[index.row()]["name"]
if role == Qt.CheckStateRole:
return Qt.Checked if self._data[index.row()]["checked"] else Qt.Unchecked
def setData(
self, index: QModelIndex, value: typing.Any, role: int = Qt.CheckStateRole
) -> bool:
if role != Qt.CheckStateRole:
return False
if not index.isValid() or index.column() > 0:
return False
# Update the checked state
self._data[index.row()]["checked"] = True if value == Qt.Checked else False
state = "checked" if value == Qt.Checked else "unchecked me"
print(f"Item '{self._data[index.row()]['name']}' is now {state}")
# Notify the view of the change
self.dataChanged.emit(index, index, [Qt.CheckStateRole])
return True
def flags(self, index: QModelIndex) -> Qt.ItemFlags:
if not index.isValid():
return Qt.NoItemFlags
return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable
def checked_items(self):
return [it["name"] for it in self._data if it["checked"]]
if __name__ == "__main__":
app = QApplication(sys.argv)
view = QListView()
model = ChoiceModel(
[{"name": "Item 1", "checked": True}, {"name": "Item 2", "checked": False}]
)
view.setModel(model)
view.show()
app.e
Mayfrom PySide6.QtWidgets import QApplication, QListView
from PySide6.QtCore import QAbstractListModel, QModelIndex, Qt
import sys
import typing
class ChoiceModel(QAbstractListModel):
def __init__(self, data: typing.List[dict]) -> None:
super().__init__()
self._data = data
de
The role is passed as an int in setData(). You compare against an Enum constant, which is always false.
You have to compare against Qt.ItemDataRole.CheckStateRole.value
Ссылка
click to show
click to show
Here's the fixed version: https://pastebin.com/Bc0Yj43D
I also ported it to use the new PySide6 scoped enums, instead of the copies in the top-level Qt namespace
ThomasHere's the fixed version: https://pastebin.com/Bc0Yj43D
I also ported it to use the new PySide6 scoped enums, instead of the copies in the top-level Qt namespace
wow, thank you bro, i tot wasnt possible , i decided to use QTableWidget and added paginations so it handle large set of data since i'm told the QAbstractListModel performs well in terms of large set of data
Performance heavily depends on your implementation. I optimized quite some abstract table models, and the one thing that makes it crawl like a snail is validation logic. Even for relatively small models, Qt performs a few thousand calls into your model. If you do complex index validations (i.e. defensive programming, always expecting invalid data), the model will be very slow with noticable lags above around 100-500ms per action you perform.
ThomasPerformance heavily depends on your implementation. I optimized quite some abstract table models, and the one thing that makes it crawl like a snail is validation logic. Even for relatively small models, Qt performs a few thousand calls into your model. If you do complex index validations (i.e. defe
ait sure, ok
id 6964974702hi guys, i need someone to assist me on how to convert a pyside6 gui to an apk
You can use auto pay to exe for this , it is a good exe convertor for pyside6 app