ChatCrawlersearch across public Telegram Open the app
Q

Qt for Python (PySide/Shiboken)

snapshot for December 2024
‹ December 2024 ›×
T
the best thing to do for us, is to create a minimal reproducible example of your broken code so that we can actually look at it to try to understand why its not working
M
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)
A
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.
M
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
K
A
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?
M
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
This was a breaking change in Qt 6.5. Most of the time, this is fine, but here it breaks
(sorry @irc for replying. Forgot that this copies the whole thing an addition time)
Also for the value. The new CheckState is passed by Qt as int and compared against CheckState enum, which is also always False.
T
Ссылка
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
T
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.
I
hi guys, i need someone to assist me on how to convert a pyside6 gui to an apk
Any qt designer online??
M
I need some guidance for creating ui for my app , if anyone is up please let me know. :)
Calendar: December 2024
MoTuWeThFrSaSu11223465617891011312131413156161718192209211222324252627328293031
Archive by month
Open in Telegram Каталог площадок Искать в ChatCrawler

A snapshot of an open public feed from the search index ChatCrawler — “Google for public Telegram”; refreshed as the venue is crawled. Times are UTC.

Public content only, official Telegram API. About · FAQ · What we do not do · Remove a page · Catalog