Qt6 QProxyStyle cause app crash
-
When you delete the style you also delete the base style as explained in the documentation (not Qt6 related):
Sets the base style that should be proxied.
Ownership of style is transferred to QProxyStyle.Therefore create a new base style instead using the QApplication default one.
-
Hey
Ok still fighting with this...
I can set a QStyle() on QProxyStyle, but how can I then set QPalette on it & styleSheet?
I tried with >
s = QStyleFactory.create("fusion") s.polish(m.getPalette()) s.setStyleShet(""" data""") ????? self.setBaseStyle(s)
Any ideas?
TIA
The problem I'm having is that I can't get it to look the same as when I take QApplication::style().
-
@Dariusz said in Qt6 QProxyStyle cause app crash:
The problem I'm having is that I can't get it to look the same as when I take QApplication::style().
Maybe your app isn't using the fusion style? Use the correct style which you app is using. The name of the style can only be retrieved via QApplication::style()->objectName() till Qt6.0, for 6.1 you can use a better function - QStyle::name() - see https://codereview.qt-project.org/c/qt/qtbase/+/328116
-
@Christian-Ehrlicher Yeah I do
In general I do something like this
app.setStyle(QStyleFactory.create("fusion")) QPalette pa /*pa set bunch of pa options */ app.setPalette(pa) app.setStyleSheet(""" style stuff""")
But the QProxyStyle sheet does not properly clone it. So I'm trying to manually make a new one, assign it and well not cause any mem error... So far I'm failing left and right.
-
When you create a new style you also have to apply your own palette if you want to same as the app style.
-
@Christian-Ehrlicher said in Qt6 QProxyStyle cause app crash:
When you create a new style you also have to apply your own palette if you want to same as the app style.
Yes but I can't get it to work.
I apply QStyle, Palette and StyleSheet to my QApp. But how can I properly replicate it ? I tried making a widget and then taking it from widget. But that did not work either. And QProxyStyle wrecks havoc when it gets a style each time. -
@Dariusz said in Qt6 QProxyStyle cause app crash:
But how can I properly replicate it ?
Apply the same things to the newly created style.
-
@Christian-Ehrlicher said in Qt6 QProxyStyle cause app crash:
@Dariusz said in Qt6 QProxyStyle cause app crash:
But how can I properly replicate it ?
Apply the same things to the newly created style.
I can't set styleSheet() on style... So I cant style the Style... o.o
-
Then don't use this approach and don't delete the proxy style.
-
@Christian-Ehrlicher So I will have memory leak... I have to delete treeview when user changes properties...
-
But why do you have to re-create the style then? Apart from that - why do you need to re-create a treeview widget at all?
-
@Christian-Ehrlicher The app creates content depending on user selection. Different content require different views as well as I can have multiple views for one content... so widgets gets made/deleted on a "normal basis". So deleting widget/treeView is a normal thing. It seems that this issue is even bigger on older OS as win7 just refuses to draw app after these "workarounds" :- (
-
Sorry but I still don't see why you need to delete and re-create the proxy style. But do what you like.