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. Segmentation fault when using setStyleSheet
Forum Updated to NodeBB v4.3 + New Features

Segmentation fault when using setStyleSheet

Scheduled Pinned Locked Moved Unsolved General and Desktop
22 Posts 5 Posters 2.0k 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.
  • L Offline
    L Offline
    lukutis222
    wrote on 16 Sept 2022, 10:14 last edited by lukutis222
    #1

    Hello. I would like to understand in a little bit more detail how setStyleSheet works and why I get Segmentation faults.

    For example, in the mainwindow.ui stylesheet I can paste the following

         QTabWidget::pane {
           border: none;
           background: rgb(25, 33, 40);
        }
        
    

    And it will work fine. However, I prefer coding styles in my constructor rather than .ui.

    I try many different syntax for exmple:

    ui->tabWidget->setStyleSheet("QTabWidget::pane { background-color: rgb(11, 33, 40)}");
    

    or

    ui->tabWidget->setStyleSheet("QTabWidget::pane{ background-color: rgb(11, 33, 40)}");
    

    or

    ui->tabWidget->setStyleSheet("QTabWidget{ background: rgb(11, 33, 40)}");
    

    or

    ui->tabWidget->setStyleSheet("QTabWidget{ background-color: rgb(11, 33, 40)}");
    

    All result in segmentation fault. Am I not using correct syntax to style my tab widget?

    J P J 3 Replies Last reply 16 Sept 2022, 10:16
    0
    • L lukutis222
      16 Sept 2022, 10:14

      Hello. I would like to understand in a little bit more detail how setStyleSheet works and why I get Segmentation faults.

      For example, in the mainwindow.ui stylesheet I can paste the following

           QTabWidget::pane {
             border: none;
             background: rgb(25, 33, 40);
          }
          
      

      And it will work fine. However, I prefer coding styles in my constructor rather than .ui.

      I try many different syntax for exmple:

      ui->tabWidget->setStyleSheet("QTabWidget::pane { background-color: rgb(11, 33, 40)}");
      

      or

      ui->tabWidget->setStyleSheet("QTabWidget::pane{ background-color: rgb(11, 33, 40)}");
      

      or

      ui->tabWidget->setStyleSheet("QTabWidget{ background: rgb(11, 33, 40)}");
      

      or

      ui->tabWidget->setStyleSheet("QTabWidget{ background-color: rgb(11, 33, 40)}");
      

      All result in segmentation fault. Am I not using correct syntax to style my tab widget?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 16 Sept 2022, 10:16 last edited by
      #2

      @lukutis222 said in Segmentation fault when using setStyleSheet:

      All result in segmentation fault. Am I not using correct syntax to style my tab widget?

      Has nothing to do with syntax (in that case you would get compiler errors).
      Simple question: is ui->tabWidget initialised when you're trying to call setStyleSheet on it?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      4
      • L lukutis222
        16 Sept 2022, 10:14

        Hello. I would like to understand in a little bit more detail how setStyleSheet works and why I get Segmentation faults.

        For example, in the mainwindow.ui stylesheet I can paste the following

             QTabWidget::pane {
               border: none;
               background: rgb(25, 33, 40);
            }
            
        

        And it will work fine. However, I prefer coding styles in my constructor rather than .ui.

        I try many different syntax for exmple:

        ui->tabWidget->setStyleSheet("QTabWidget::pane { background-color: rgb(11, 33, 40)}");
        

        or

        ui->tabWidget->setStyleSheet("QTabWidget::pane{ background-color: rgb(11, 33, 40)}");
        

        or

        ui->tabWidget->setStyleSheet("QTabWidget{ background: rgb(11, 33, 40)}");
        

        or

        ui->tabWidget->setStyleSheet("QTabWidget{ background-color: rgb(11, 33, 40)}");
        

        All result in segmentation fault. Am I not using correct syntax to style my tab widget?

        P Offline
        P Offline
        Pl45m4
        wrote on 16 Sept 2022, 10:20 last edited by Pl45m4
        #3

        @lukutis222

        It looks like there is an issue wth your ui or tabWidget pointer rather than a problem with your stylesheet code.
        Usually if you mess up you stylesheet, the style simply wont apply, but from my experience the code still runs.

        Do you delete your tabWidget somewhere (intentionally or not) before you apply the style?

        @jsulm Sry :) Took to long to write :o)


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        1 Reply Last reply
        3
        • L lukutis222
          16 Sept 2022, 10:14

          Hello. I would like to understand in a little bit more detail how setStyleSheet works and why I get Segmentation faults.

          For example, in the mainwindow.ui stylesheet I can paste the following

               QTabWidget::pane {
                 border: none;
                 background: rgb(25, 33, 40);
              }
              
          

          And it will work fine. However, I prefer coding styles in my constructor rather than .ui.

          I try many different syntax for exmple:

          ui->tabWidget->setStyleSheet("QTabWidget::pane { background-color: rgb(11, 33, 40)}");
          

          or

          ui->tabWidget->setStyleSheet("QTabWidget::pane{ background-color: rgb(11, 33, 40)}");
          

          or

          ui->tabWidget->setStyleSheet("QTabWidget{ background: rgb(11, 33, 40)}");
          

          or

          ui->tabWidget->setStyleSheet("QTabWidget{ background-color: rgb(11, 33, 40)}");
          

          All result in segmentation fault. Am I not using correct syntax to style my tab widget?

          J Online
          J Online
          JonB
          wrote on 16 Sept 2022, 10:26 last edited by JonB
          #4

          @lukutis222
          And further to the above (correct) replies. Whenever you have a "segmentation fault" (or other similar) you should be running your program under the debugger. That will break on the fault. You then look in the stack trace pane to see where this emanated from in your code, perhaps examining variables, and you should have a good clue. For example, this would show you if indeed your ui->tabWidget is null or invalid.

          1 Reply Last reply
          0
          • J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on 16 Sept 2022, 10:36 last edited by
            #5

            put the :
            ui->tabWidget->setStyleSheet....

            after the ui->setupUi(this); call.


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            L 1 Reply Last reply 16 Sept 2022, 11:09
            2
            • J.HilkJ J.Hilk
              16 Sept 2022, 10:36

              put the :
              ui->tabWidget->setStyleSheet....

              after the ui->setupUi(this); call.

              L Offline
              L Offline
              lukutis222
              wrote on 16 Sept 2022, 11:09 last edited by lukutis222
              #6

              Thanks all for quick responses.
              I do not destroy or delete that tab widget anywhere. The structure of my widgets are as following:

              001b05f4-97d4-4891-a6ca-9b7e79fa88d8-image.png

              I have tried to call the setStyleSheet after setuipUI and that fixed my segmentation fault.. However, I would still like to understand about this QTabWidget and why no color is applied.

              I can do:

              ui->tab_3->setStyleSheet("QWidget { background-color: rgb(11, 33, 40);border: 1px solid white;}");
              

              And the color will be applied (blackish color):
              c90b7567-ee54-481e-bd59-c4bccb7642fc-image.png

              When I do:

              ui->tabWidget->setStyleSheet("QTabWidget { background-color: rgb(11, 33, 40)}");
              

              Nothing is styled:
              8ba45435-5d18-4e01-b00f-a20b7b9cac37-image.png

              J J 2 Replies Last reply 16 Sept 2022, 11:12
              0
              • L lukutis222
                16 Sept 2022, 11:09

                Thanks all for quick responses.
                I do not destroy or delete that tab widget anywhere. The structure of my widgets are as following:

                001b05f4-97d4-4891-a6ca-9b7e79fa88d8-image.png

                I have tried to call the setStyleSheet after setuipUI and that fixed my segmentation fault.. However, I would still like to understand about this QTabWidget and why no color is applied.

                I can do:

                ui->tab_3->setStyleSheet("QWidget { background-color: rgb(11, 33, 40);border: 1px solid white;}");
                

                And the color will be applied (blackish color):
                c90b7567-ee54-481e-bd59-c4bccb7642fc-image.png

                When I do:

                ui->tabWidget->setStyleSheet("QTabWidget { background-color: rgb(11, 33, 40)}");
                

                Nothing is styled:
                8ba45435-5d18-4e01-b00f-a20b7b9cac37-image.png

                J Online
                J Online
                JonB
                wrote on 16 Sept 2022, 11:12 last edited by JonB
                #7

                @lukutis222 said in Segmentation fault when using setStyleSheet:

                ui->tab_3->setStyleSheet("QWidget { background-color: rgb(11, 33, 40);border: 1px solid white;}");

                ui->tabWidget->setStyleSheet("QTabWidget { background-color: rgb(11, 33, 40)}");

                The first styles all QWidgets, the second only QTabWidget. Is that what you are testing? I trust you are copying these statements from actual code.

                L 1 Reply Last reply 16 Sept 2022, 11:14
                0
                • L lukutis222
                  16 Sept 2022, 11:09

                  Thanks all for quick responses.
                  I do not destroy or delete that tab widget anywhere. The structure of my widgets are as following:

                  001b05f4-97d4-4891-a6ca-9b7e79fa88d8-image.png

                  I have tried to call the setStyleSheet after setuipUI and that fixed my segmentation fault.. However, I would still like to understand about this QTabWidget and why no color is applied.

                  I can do:

                  ui->tab_3->setStyleSheet("QWidget { background-color: rgb(11, 33, 40);border: 1px solid white;}");
                  

                  And the color will be applied (blackish color):
                  c90b7567-ee54-481e-bd59-c4bccb7642fc-image.png

                  When I do:

                  ui->tabWidget->setStyleSheet("QTabWidget { background-color: rgb(11, 33, 40)}");
                  

                  Nothing is styled:
                  8ba45435-5d18-4e01-b00f-a20b7b9cac37-image.png

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 16 Sept 2022, 11:13 last edited by
                  #8

                  @lukutis222 I guess you need to set the color on QTabWidget::pane like shown here: https://doc.qt.io/qt-6/stylesheet-examples.html

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  L 1 Reply Last reply 16 Sept 2022, 11:15
                  0
                  • J JonB
                    16 Sept 2022, 11:12

                    @lukutis222 said in Segmentation fault when using setStyleSheet:

                    ui->tab_3->setStyleSheet("QWidget { background-color: rgb(11, 33, 40);border: 1px solid white;}");

                    ui->tabWidget->setStyleSheet("QTabWidget { background-color: rgb(11, 33, 40)}");

                    The first styles all QWidgets, the second only QTabWidget. Is that what you are testing? I trust you are copying these statements from actual code.

                    L Offline
                    L Offline
                    lukutis222
                    wrote on 16 Sept 2022, 11:14 last edited by
                    #9

                    @JonB
                    Yes. I would expect to see my whole tab in black color ( similar to when I color the whole widget in black color)

                    1 Reply Last reply
                    0
                    • J jsulm
                      16 Sept 2022, 11:13

                      @lukutis222 I guess you need to set the color on QTabWidget::pane like shown here: https://doc.qt.io/qt-6/stylesheet-examples.html

                      L Offline
                      L Offline
                      lukutis222
                      wrote on 16 Sept 2022, 11:15 last edited by
                      #10

                      @jsulm
                      Yes but how can I do that in code rather than UI?
                      in UI I use

                          /*
                           *     QTabWidget::pane {
                             border: none;
                             background: rgb(25, 33, 40);
                          }
                          */
                      

                      But how can I add pane in code?

                      ui->tabWidget->setStyleSheet("QTabWidget::pane { background-color: rgb(11, 33, 40)}");
                      

                      I tried below and that changes nothing

                      J 1 Reply Last reply 16 Sept 2022, 11:22
                      0
                      • L lukutis222
                        16 Sept 2022, 11:15

                        @jsulm
                        Yes but how can I do that in code rather than UI?
                        in UI I use

                            /*
                             *     QTabWidget::pane {
                               border: none;
                               background: rgb(25, 33, 40);
                            }
                            */
                        

                        But how can I add pane in code?

                        ui->tabWidget->setStyleSheet("QTabWidget::pane { background-color: rgb(11, 33, 40)}");
                        

                        I tried below and that changes nothing

                        J Online
                        J Online
                        JonB
                        wrote on 16 Sept 2022, 11:22 last edited by JonB
                        #11

                        @lukutis222
                        I don't understand. If you say "in UI I use" (and I assume you mean it works)

                        QTabWidget::pane {
                               border: none;
                               background: rgb(25, 33, 40);
                        }
                        

                        then in code you can use setStyleSheet("QTabWidget::pane { border: none; background-color: rgb(25, 33, 40); }"). You can even look in the generated ui_....h file to see exactly what statement is generated for what object where from the QSS you type in.

                        L 1 Reply Last reply 16 Sept 2022, 11:38
                        2
                        • J JonB
                          16 Sept 2022, 11:22

                          @lukutis222
                          I don't understand. If you say "in UI I use" (and I assume you mean it works)

                          QTabWidget::pane {
                                 border: none;
                                 background: rgb(25, 33, 40);
                          }
                          

                          then in code you can use setStyleSheet("QTabWidget::pane { border: none; background-color: rgb(25, 33, 40); }"). You can even look in the generated ui_....h file to see exactly what statement is generated for what object where from the QSS you type in.

                          L Offline
                          L Offline
                          lukutis222
                          wrote on 16 Sept 2022, 11:38 last edited by lukutis222
                          #12

                          @JonB
                          When I go to my mainwindow.ui, right click the application window -> Change styleSheet and input the following:

                          QTabWidget::pane {
                                 border: none;
                                 background: rgb(25, 33, 40);
                          }
                          

                          The style applies:
                          86d34e3f-c48c-4bf9-87b7-fabf20f981a7-image.png

                          I checked the style file:

                          <?xml version="1.0" encoding="UTF-8"?>
                          <ui version="4.0">
                           <class>MainWindow</class>
                           <widget class="QMainWindow" name="MainWindow">
                            <property name="geometry">
                             <rect>
                              <x>0</x>
                              <y>0</y>
                              <width>800</width>
                              <height>600</height>
                             </rect>
                            </property>
                            <property name="windowTitle">
                             <string>MainWindow</string>
                            </property>
                            <widget class="QWidget" name="centralwidget">
                             <layout class="QVBoxLayout" name="verticalLayout_3">
                              <item>
                               <widget class="QTabWidget" name="tabWidget">
                                <property name="styleSheet">
                                 <string notr="true">
                              QTabWidget::pane { 
                                 border: none;
                                 background: rgb(25, 33, 40);
                              }
                          

                          I cannot wrap my head around what is wrong with this and why the style does not apply

                              ui->setupUi(this);
                              ui->tabWidget->setStyleSheet("QTabWidget { background-color: rgb(11, 33, 40)}");
                          
                          J J 2 Replies Last reply 16 Sept 2022, 11:41
                          0
                          • L lukutis222
                            16 Sept 2022, 11:38

                            @JonB
                            When I go to my mainwindow.ui, right click the application window -> Change styleSheet and input the following:

                            QTabWidget::pane {
                                   border: none;
                                   background: rgb(25, 33, 40);
                            }
                            

                            The style applies:
                            86d34e3f-c48c-4bf9-87b7-fabf20f981a7-image.png

                            I checked the style file:

                            <?xml version="1.0" encoding="UTF-8"?>
                            <ui version="4.0">
                             <class>MainWindow</class>
                             <widget class="QMainWindow" name="MainWindow">
                              <property name="geometry">
                               <rect>
                                <x>0</x>
                                <y>0</y>
                                <width>800</width>
                                <height>600</height>
                               </rect>
                              </property>
                              <property name="windowTitle">
                               <string>MainWindow</string>
                              </property>
                              <widget class="QWidget" name="centralwidget">
                               <layout class="QVBoxLayout" name="verticalLayout_3">
                                <item>
                                 <widget class="QTabWidget" name="tabWidget">
                                  <property name="styleSheet">
                                   <string notr="true">
                                QTabWidget::pane { 
                                   border: none;
                                   background: rgb(25, 33, 40);
                                }
                            

                            I cannot wrap my head around what is wrong with this and why the style does not apply

                                ui->setupUi(this);
                                ui->tabWidget->setStyleSheet("QTabWidget { background-color: rgb(11, 33, 40)}");
                            
                            J Online
                            J Online
                            JonB
                            wrote on 16 Sept 2022, 11:41 last edited by
                            #13

                            @lukutis222 said in Segmentation fault when using setStyleSheet:

                            QTabWidget::pane {

                            ui->tabWidget->setStyleSheet("QTabWidget { background-color: rgb(11, 33, 40)}");

                            But now you have gone back to not specifying QTabWidget::pane in your code version. It's really hard to keep up if these things are not consistent....

                            L 1 Reply Last reply 16 Sept 2022, 11:42
                            0
                            • L lukutis222
                              16 Sept 2022, 11:38

                              @JonB
                              When I go to my mainwindow.ui, right click the application window -> Change styleSheet and input the following:

                              QTabWidget::pane {
                                     border: none;
                                     background: rgb(25, 33, 40);
                              }
                              

                              The style applies:
                              86d34e3f-c48c-4bf9-87b7-fabf20f981a7-image.png

                              I checked the style file:

                              <?xml version="1.0" encoding="UTF-8"?>
                              <ui version="4.0">
                               <class>MainWindow</class>
                               <widget class="QMainWindow" name="MainWindow">
                                <property name="geometry">
                                 <rect>
                                  <x>0</x>
                                  <y>0</y>
                                  <width>800</width>
                                  <height>600</height>
                                 </rect>
                                </property>
                                <property name="windowTitle">
                                 <string>MainWindow</string>
                                </property>
                                <widget class="QWidget" name="centralwidget">
                                 <layout class="QVBoxLayout" name="verticalLayout_3">
                                  <item>
                                   <widget class="QTabWidget" name="tabWidget">
                                    <property name="styleSheet">
                                     <string notr="true">
                                  QTabWidget::pane { 
                                     border: none;
                                     background: rgb(25, 33, 40);
                                  }
                              

                              I cannot wrap my head around what is wrong with this and why the style does not apply

                                  ui->setupUi(this);
                                  ui->tabWidget->setStyleSheet("QTabWidget { background-color: rgb(11, 33, 40)}");
                              
                              J Offline
                              J Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on 16 Sept 2022, 11:41 last edited by
                              #14

                              @lukutis222 And did you also check the generated ui_*.h file like @JonB suggested to see how the style-sheet is set there?

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              L 1 Reply Last reply 16 Sept 2022, 11:46
                              0
                              • J JonB
                                16 Sept 2022, 11:41

                                @lukutis222 said in Segmentation fault when using setStyleSheet:

                                QTabWidget::pane {

                                ui->tabWidget->setStyleSheet("QTabWidget { background-color: rgb(11, 33, 40)}");

                                But now you have gone back to not specifying QTabWidget::pane in your code version. It's really hard to keep up if these things are not consistent....

                                L Offline
                                L Offline
                                lukutis222
                                wrote on 16 Sept 2022, 11:42 last edited by
                                #15

                                @JonB

                                Both are not working. I can even call:

                                
                                    ui->setupUi(this);
                                    ui->tabWidget->setStyleSheet("QTabWidget { background-color: rgb(11, 33, 40)}");
                                    ui->tabWidget->setStyleSheet("QTabWidget::pane { background-color: rgb(11, 33, 40)}");
                                
                                J 1 Reply Last reply 16 Sept 2022, 11:48
                                0
                                • J jsulm
                                  16 Sept 2022, 11:41

                                  @lukutis222 And did you also check the generated ui_*.h file like @JonB suggested to see how the style-sheet is set there?

                                  L Offline
                                  L Offline
                                  lukutis222
                                  wrote on 16 Sept 2022, 11:46 last edited by lukutis222
                                  #16

                                  @jsulm I assume you are talking about this

                                  <?xml version="1.0" encoding="UTF-8"?>
                                  <ui version="4.0">
                                   <class>MainWindow</class>
                                   <widget class="QMainWindow" name="MainWindow">
                                    <property name="geometry">
                                     <rect>
                                      <x>0</x>
                                      <y>0</y>
                                      <width>800</width>
                                      <height>600</height>
                                     </rect>
                                    </property>
                                    <property name="windowTitle">
                                     <string>MainWindow</string>
                                    </property>
                                    <widget class="QWidget" name="centralwidget">
                                     <layout class="QVBoxLayout" name="verticalLayout_3">
                                      <item>
                                       <widget class="QTabWidget" name="tabWidget">
                                        <property name="styleSheet">
                                         <string notr="true">QTabWidget::pane { 
                                         border: none;
                                         background: rgb(25, 33, 40);
                                      }
                                  

                                  The above is when I edit style sheet in UI instead of code which seems identical to what I am calling in code and it does not work

                                  ui->tabWidget->setStyleSheet("QTabWidget::pane { background-color: rgb(25, 33, 40)}");
                                  
                                  J J 2 Replies Last reply 16 Sept 2022, 11:48
                                  0
                                  • L lukutis222
                                    16 Sept 2022, 11:42

                                    @JonB

                                    Both are not working. I can even call:

                                    
                                        ui->setupUi(this);
                                        ui->tabWidget->setStyleSheet("QTabWidget { background-color: rgb(11, 33, 40)}");
                                        ui->tabWidget->setStyleSheet("QTabWidget::pane { background-color: rgb(11, 33, 40)}");
                                    
                                    J Online
                                    J Online
                                    JonB
                                    wrote on 16 Sept 2022, 11:48 last edited by
                                    #17

                                    @lukutis222

                                    • Start by using the same copied stuff between the two examples. Don't (at this stage) have, for example, one specifying border and compare against the other not specifying border, until you have got both working consistently.

                                    • The stuff done in the Designer does not work "by magic". The .ui file is not read at runtime. The uic generates the ui_....h file, the C++ code includes that and calls setupUi(). Logic tells you that you must be able to achieve the same in your "manual" code. So you must be able to reproduce. You have some subtle difference somewhere in what you are coding versus what happens from the Designer stuff, so start by getting them identical before you allow any differences.

                                    1 Reply Last reply
                                    0
                                    • L lukutis222
                                      16 Sept 2022, 11:46

                                      @jsulm I assume you are talking about this

                                      <?xml version="1.0" encoding="UTF-8"?>
                                      <ui version="4.0">
                                       <class>MainWindow</class>
                                       <widget class="QMainWindow" name="MainWindow">
                                        <property name="geometry">
                                         <rect>
                                          <x>0</x>
                                          <y>0</y>
                                          <width>800</width>
                                          <height>600</height>
                                         </rect>
                                        </property>
                                        <property name="windowTitle">
                                         <string>MainWindow</string>
                                        </property>
                                        <widget class="QWidget" name="centralwidget">
                                         <layout class="QVBoxLayout" name="verticalLayout_3">
                                          <item>
                                           <widget class="QTabWidget" name="tabWidget">
                                            <property name="styleSheet">
                                             <string notr="true">QTabWidget::pane { 
                                             border: none;
                                             background: rgb(25, 33, 40);
                                          }
                                      

                                      The above is when I edit style sheet in UI instead of code which seems identical to what I am calling in code and it does not work

                                      ui->tabWidget->setStyleSheet("QTabWidget::pane { background-color: rgb(25, 33, 40)}");
                                      
                                      J Offline
                                      J Offline
                                      jsulm
                                      Lifetime Qt Champion
                                      wrote on 16 Sept 2022, 11:48 last edited by
                                      #18

                                      @lukutis222 said in Segmentation fault when using setStyleSheet:

                                      I assume you are talking about this

                                      No, I'm not.
                                      "generated ui_*.h file" - has nothing to do with XML file you're showing...

                                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      L 1 Reply Last reply 16 Sept 2022, 11:48
                                      0
                                      • J jsulm
                                        16 Sept 2022, 11:48

                                        @lukutis222 said in Segmentation fault when using setStyleSheet:

                                        I assume you are talking about this

                                        No, I'm not.
                                        "generated ui_*.h file" - has nothing to do with XML file you're showing...

                                        L Offline
                                        L Offline
                                        lukutis222
                                        wrote on 16 Sept 2022, 11:48 last edited by
                                        #19

                                        @jsulm Can you explain where can I find that magic file you are talking about, because I cannot see it in my project file list

                                        J J 2 Replies Last reply 16 Sept 2022, 11:50
                                        0
                                        • L lukutis222
                                          16 Sept 2022, 11:46

                                          @jsulm I assume you are talking about this

                                          <?xml version="1.0" encoding="UTF-8"?>
                                          <ui version="4.0">
                                           <class>MainWindow</class>
                                           <widget class="QMainWindow" name="MainWindow">
                                            <property name="geometry">
                                             <rect>
                                              <x>0</x>
                                              <y>0</y>
                                              <width>800</width>
                                              <height>600</height>
                                             </rect>
                                            </property>
                                            <property name="windowTitle">
                                             <string>MainWindow</string>
                                            </property>
                                            <widget class="QWidget" name="centralwidget">
                                             <layout class="QVBoxLayout" name="verticalLayout_3">
                                              <item>
                                               <widget class="QTabWidget" name="tabWidget">
                                                <property name="styleSheet">
                                                 <string notr="true">QTabWidget::pane { 
                                                 border: none;
                                                 background: rgb(25, 33, 40);
                                              }
                                          

                                          The above is when I edit style sheet in UI instead of code which seems identical to what I am calling in code and it does not work

                                          ui->tabWidget->setStyleSheet("QTabWidget::pane { background-color: rgb(25, 33, 40)}");
                                          
                                          J Online
                                          J Online
                                          JonB
                                          wrote on 16 Sept 2022, 11:49 last edited by
                                          #20

                                          @lukutis222 said in Segmentation fault when using setStyleSheet:

                                          ui->tabWidget->setStyleSheet("QTabWidget::pane { background-color: rgb(25, 33, 40)}");

                                          Yet again: start by copying what you have working in the .ui, not assuming that the border: none; is irrelevant. How hard can it be to copy? Maybe this is irrelevant, but just maybe it is significant, why take the risk?

                                          1 Reply Last reply
                                          0

                                          1/22

                                          16 Sept 2022, 10:14

                                          • Login

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