Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt6 QProxyStyle cause app crash
Forum Updated to NodeBB v4.3 + New Features

Qt6 QProxyStyle cause app crash

Scheduled Pinned Locked Moved Unsolved General and Desktop
qproxystyleqstyleqapplication
17 Posts 4 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Christian EhrlicherC Online
    Christian EhrlicherC Online
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on last edited by
    #5

    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.

    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
    Visit the Qt Academy at https://academy.qt.io/catalog

    1 Reply Last reply
    1
    • D Offline
      D Offline
      Dariusz
      wrote on last edited by Dariusz
      #6

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

      1 Reply Last reply
      0
      • Christian EhrlicherC Online
        Christian EhrlicherC Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #7

        @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

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        D 1 Reply Last reply
        0
        • Christian EhrlicherC Christian Ehrlicher

          @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

          D Offline
          D Offline
          Dariusz
          wrote on last edited by
          #8

          @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.

          1 Reply Last reply
          0
          • Christian EhrlicherC Online
            Christian EhrlicherC Online
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #9

            When you create a new style you also have to apply your own palette if you want to same as the app style.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            D 1 Reply Last reply
            0
            • Christian EhrlicherC Christian Ehrlicher

              When you create a new style you also have to apply your own palette if you want to same as the app style.

              D Offline
              D Offline
              Dariusz
              wrote on last edited by
              #10

              @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.

              1 Reply Last reply
              0
              • Christian EhrlicherC Online
                Christian EhrlicherC Online
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #11

                @Dariusz said in Qt6 QProxyStyle cause app crash:

                But how can I properly replicate it ?

                Apply the same things to the newly created style.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                D 1 Reply Last reply
                0
                • Christian EhrlicherC Christian Ehrlicher

                  @Dariusz said in Qt6 QProxyStyle cause app crash:

                  But how can I properly replicate it ?

                  Apply the same things to the newly created style.

                  D Offline
                  D Offline
                  Dariusz
                  wrote on last edited by
                  #12

                  @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

                  1 Reply Last reply
                  0
                  • Christian EhrlicherC Online
                    Christian EhrlicherC Online
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by Christian Ehrlicher
                    #13

                    Then don't use this approach and don't delete the proxy style.

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    D 1 Reply Last reply
                    0
                    • Christian EhrlicherC Christian Ehrlicher

                      Then don't use this approach and don't delete the proxy style.

                      D Offline
                      D Offline
                      Dariusz
                      wrote on last edited by
                      #14

                      @Christian-Ehrlicher So I will have memory leak... I have to delete treeview when user changes properties...

                      1 Reply Last reply
                      0
                      • Christian EhrlicherC Online
                        Christian EhrlicherC Online
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on last edited by
                        #15

                        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?

                        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                        Visit the Qt Academy at https://academy.qt.io/catalog

                        D 1 Reply Last reply
                        0
                        • Christian EhrlicherC Christian Ehrlicher

                          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?

                          D Offline
                          D Offline
                          Dariusz
                          wrote on last edited by
                          #16

                          @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" :- (

                          1 Reply Last reply
                          0
                          • Christian EhrlicherC Online
                            Christian EhrlicherC Online
                            Christian Ehrlicher
                            Lifetime Qt Champion
                            wrote on last edited by
                            #17

                            Sorry but I still don't see why you need to delete and re-create the proxy style. But do what you like.

                            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                            Visit the Qt Academy at https://academy.qt.io/catalog

                            1 Reply Last reply
                            0

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved