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.
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)
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
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.
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.
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.
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)
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)?
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?