ChatCrawlersearch across public Telegram Open the app
Q

Qt for Python (PySide/Shiboken)

snapshot for October 2023
‹ October 2023 ›×
19 October 2023
T
Markus Bauertext not yet in the index
I'm relatively sure that doing only @Property(bool, notify=Signal(name="runFilterChanged")) will cause the Signal() instance (the PyObject wrapping the underlying C++ object) to get GC'ed, but I'm not 100% on that. If you pass something to a Qt function, it will not keep a reference to the PyObject, but only the wrapped object. If there's no reference to the wrapper in Python code, the GC will eat it.
23 October 2023
M
Heyho This is a follow up So my signals are working, but I am now struggling with the QAbstractTableModel So I have filters I apply but turning them On/Off and change the query Now I try to tell the Viewer, that the data is changed: self.dataChanged.emit(self.createIndex(0,0), self.createIndex(self.rowCount(None), self.columnCount(None)), None) But this crashes totally my design Somehow I do not really understand why this is happening or what would be the best way to give this hint, as I don't relly know, if I am adding or removing (I could make a rowCount difference but sounds odd)
so that's what I get file:///C:/Users/Markus/Documents/Python/TTT-TimeTrackTool/src/qml/pages/projectsPage.qml:128:29: Unable to assign [undefined] to QString file:///C:/Users/Markus/Documents/Python/TTT-TimeTrackTool/src/qml/pages/projectsPage.qml:128:29: Unable to assign [undefined] to QString file:///C:/Users/Markus/Documents/Python/TTT-TimeTrackTool/src/qml/pages/projectsPage.qml:128:29: Unable to assign [undefined] to QString file:///C:/Users/Markus/Documents/Python/TTT-TimeTrackTool/src/qml/pages/projectsPage.qml:128:29: Unable to assign [undefined] to QString file:///C:/Users/Markus/Documents/Python/TTT-TimeTrackTool/src/qml/pages/projectsPage.qml:128:29: Unable to assign [undefined] to QString file:///C:/Users/Markus/Documents/Python/TTT-TimeTrackTool/src/qml/pages/projectsPage.qml:128:29: Unable to assign [undefined] to QString TableView: failed loading index: 117 TableView: failed loading index: 149 TableView: failed loading index: 181 TableView: failed loading index: 118 TableView: failed loading index: 150 TableView: failed loading index: 182 TableView: failed loading index: 119 TableView: failed loading index: 151 TableView: failed loading index: 183 TableView: failed loading index: 120 TableView: failed loading index: 152
T
If the filter totally changes the model content with potential row count changes, I'd try to emit the modelAboutToBeReset + modelReset signals or the mentionedlayoutAbouttoBeChanged + layoutChanged
L
In general if your functions interacts with indexes layoutChanged is what you are looking for
This is the way, if the data changes drastically. If you can determine that the differences are small and somewhat well behaved to have a reasonable small diff, you could also compute the diff, and then emit the rowsInserted/rowsRemoved signals to indicate all changes individually. But that's more or less theoretical.
T
Ссылка
click to show
Those are signal pairs, one goes before a data change, one goes after. See the table https://doc.qt.io/qt-6/qabstractitemmodel.html#signals. Most are emit implicitly by the protected methods, for example beginInsertColumns()/endInsertColumns(). Notably, layout(AboutToBe)Changed has no such method pair. A well behaved model emits both, so that UIs can adjust accordingly. Maybe the UI wants to look at removed things, before the model deletes them, etc.
L
I had to bug hunting for hours when my side-effects were not working properly
K
Generally - if you're having real weirdness or crashes that involve abstract models, look at the places that change model contents and indices changes etc, and make sure they have the requisite pairs of notifier signals.
M
So easiest case, I just do both
24 October 2023
K
Well, if you invalidate the whole model every time something changes, that can be bad performance-wise.
25 October 2023
I
Hey everyone, I'm starting to use QT Designer and PySide6, and I have a question. In the code below, the button color and the button text color are not applied. No errors occur, but the color remains the same. What could be missing? Please help me. import sys from PySide6.QtWidgets import QMainWindow, QApplication, QStyleFactory from MainWindow_Dark_Light import Ui_MainWindow import styles class MainWindow(QMainWindow, Ui_MainWindow): def init(self): super(MainWindow, self).init() self.setupUi(self) self.btn_Dark.clicked.connect(self.set_dark) self.btn_Light.clicked.connect(self.set_light) def set_dark(self): app = QApplication.instance() styles.dark(app) def set_light(self): app = QApplication.instance() styles.light(app) app = QApplication() # Definir o estilo "Fusion" app.setStyle(QStyleFactory.create('Fusion')) w = MainWindow() w.show() # styles.dark(app) app.exec() ———————————————————————————- from PySide6.QtGui import QPalette, QColor, QBrush from PySide6.QtCore import Qt def dark(app): darkPalette = QPalette() # darkPalette = QBrush() darkPalette.setColor(QPalette.Window, QColor(53, 53, 53)) darkPalette.setColor(QPalette.WindowText, QColor(121, 121, 121)) darkPalette.setColor(QPalette.Button, QColor(0, 0, 0)) darkPalette.setColor(QPalette.ButtonText, QColor(255, 255, 255)) app.setPalette(darkPalette) def light(app): lightPalette = QPalette() lightPalette.setColor(QPalette.Window, QColor(255, 255, 255)) lightPalette.setColor(QPalette.WindowText, QColor(0, 0, 0)) lightPalette.setColor(QPalette.Button, QColor(255, 255, 255)) lightPalette.setColor(QPalette.ButtonText, QColor(0, 0, 0)) app.setPalette(lightPalette)
26 October 2023
M
Hey With QT6.5 there is a build in function to handle the TableView size of Column and Row What is the best way to safe this layout on exit? Component.onCompleted Component.onDestruction And just load and save the sizes by iterating over the columns with columnWidth(int column)?
27 October 2023
I
Hey, I'm facing a bit of an issue with my devices because of a bug that popped up after updating to QT version 5.15.2. I've actually reported the bug. Unfortunately it hasn't really received attention for about a year and a half now. https://bugreports.qt.io/browse/QTBUG-104771 So in order to move forward with our project we're starting from scratch using PySide6 and QML. The only problem is that we're currently using Python 3.9 and I was wondering if it's possible to build PySide2 5.15.1 to work with Python 3.11?
M
I am running Python 3.9.6 with PySide6==6.5.3
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