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. Can I color a layout that is empty?

Can I color a layout that is empty?

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 4 Posters 1.2k Views
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I have a layout that I want to color with white

    jsulmJ 1 Reply Last reply
    0
    • ? A Former User

      I have a layout that I want to color with white

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @vale88 A layout is not a widget and cannot be colored. You will need to put a widget into this layout and color the widget instead.

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

      ? 1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        Can i ask why you want to color an empty layout ?

        1 Reply Last reply
        0
        • jsulmJ jsulm

          @vale88 A layout is not a widget and cannot be colored. You will need to put a widget into this layout and color the widget instead.

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          @jsulm ok, I'm coloring the groupBox inside, I colored the background of the groupBox, now I want to colore the border, but in this way:
          ui->groupBox_3->setStyleSheet("QGroupBox: { border: 2px solid gray; }");
          the groupBox becomes transparent without the color inside also

          1 Reply Last reply
          0
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi
            Combine both stylesheets to one so you both set color and also background.

            ? 1 Reply Last reply
            1
            • mrjjM mrjj

              Hi
              Combine both stylesheets to one so you both set color and also background.

              ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              @mrjj I wrote:
              ui->groupBox_3->setStyleSheet("QGroupBox: { border-color:rgb(117,117,117); background-color:rgb(117,117,117)}");
              but It doesn't work, the groupBox becomes Transparent

              mrjjM J.HilkJ 2 Replies Last reply
              0
              • ? A Former User

                @mrjj I wrote:
                ui->groupBox_3->setStyleSheet("QGroupBox: { border-color:rgb(117,117,117); background-color:rgb(117,117,117)}");
                but It doesn't work, the groupBox becomes Transparent

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @vale88
                It does work but you have to specify more

                QGroupBox {
                 background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                                   stop: 0 #E0E0E0, stop: 1 #FFFFFF);
                 border: 2px solid gray;
                 border-radius: 5px;
                 margin-top: 1ex; /* leave space at the top for the title */
                }
                

                alt text

                ? 1 Reply Last reply
                2
                • ? A Former User

                  @mrjj I wrote:
                  ui->groupBox_3->setStyleSheet("QGroupBox: { border-color:rgb(117,117,117); background-color:rgb(117,117,117)}");
                  but It doesn't work, the groupBox becomes Transparent

                  J.HilkJ Offline
                  J.HilkJ Offline
                  J.Hilk
                  Moderators
                  wrote on last edited by
                  #8

                  @vale88 you're missing a ;at the end.
                  It makes a difference ;)


                  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.

                  1 Reply Last reply
                  2
                  • mrjjM mrjj

                    @vale88
                    It does work but you have to specify more

                    QGroupBox {
                     background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                                       stop: 0 #E0E0E0, stop: 1 #FFFFFF);
                     border: 2px solid gray;
                     border-radius: 5px;
                     margin-top: 1ex; /* leave space at the top for the title */
                    }
                    

                    alt text

                    ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #9

                    @mrjj it works but the groupBox seems to have border circular and the inside isn't the same color gray of the background

                    ? 1 Reply Last reply
                    0
                    • ? A Former User

                      @mrjj it works but the groupBox seems to have border circular and the inside isn't the same color gray of the background

                      ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #10

                      @vale88
                      and the inside isn't the same color gray of the border, I wanted to say

                      ? mrjjM 2 Replies Last reply
                      0
                      • ? A Former User

                        @vale88
                        and the inside isn't the same color gray of the border, I wanted to say

                        ? Offline
                        ? Offline
                        A Former User
                        wrote on last edited by
                        #11

                        @vale88 I solved, thank you

                        1 Reply Last reply
                        0
                        • ? A Former User

                          @vale88
                          and the inside isn't the same color gray of the border, I wanted to say

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @vale88
                          Well it was just sample.
                          i expected you to change colors to what you wanted :)

                          But actaully @J-Hilk's hawk eye spotted the real issue it does work then

                          QGroupBox { 
                          border-color:rgb(117,117,117); 
                          background-color:rgb(117,117,117);
                          };
                          
                          J.HilkJ 1 Reply Last reply
                          1
                          • mrjjM mrjj

                            @vale88
                            Well it was just sample.
                            i expected you to change colors to what you wanted :)

                            But actaully @J-Hilk's hawk eye spotted the real issue it does work then

                            QGroupBox { 
                            border-color:rgb(117,117,117); 
                            background-color:rgb(117,117,117);
                            };
                            
                            J.HilkJ Offline
                            J.HilkJ Offline
                            J.Hilk
                            Moderators
                            wrote on last edited by
                            #13

                            @mrjj

                            But actaully @J-Hilk's hawk eye spotted the real issue it does work then

                            a skill earend through countless hours of suffering...

                            I have spend days fighting with the stylesheet, only to learn I had it right in the beginning, but a ; was missing

                            🙈


                            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.

                            1 Reply Last reply
                            2

                            • Login

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