Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to set the background color for gridLaout?
Forum Updated to NodeBB v4.3 + New Features

How to set the background color for gridLaout?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
10 Posts 2 Posters 3.8k 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.
  • A Offline
    A Offline
    amarism
    wrote on last edited by
    #1

    I have a grid layout and i want to fix the background to black. But, I am not able to fix the color. Bcz gridLayout have no method "setStyleSheet".

    ODБOïO 1 Reply Last reply
    0
    • A amarism

      I have a grid layout and i want to fix the background to black. But, I am not able to fix the color. Bcz gridLayout have no method "setStyleSheet".

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      hi @amarism
      Rectangle{
      color:backgroundColor
      GridLayout{}
      }

      A 1 Reply Last reply
      0
      • ODБOïO ODБOï

        hi @amarism
        Rectangle{
        color:backgroundColor
        GridLayout{}
        }

        A Offline
        A Offline
        amarism
        wrote on last edited by
        #3

        @LeLev i will use this one code still not working for me

        import QtQuick 2.5
        import QtQuick.Layouts 1.1
        
        Rectangle{
             color:black
             GridLayout{}
        }
        
        ODБOïO 1 Reply Last reply
        0
        • A amarism

          @LeLev i will use this one code still not working for me

          import QtQuick 2.5
          import QtQuick.Layouts 1.1
          
          Rectangle{
               color:black
               GridLayout{}
          }
          
          ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by
          #4

          @amarism

          color:"black"
          
          A 1 Reply Last reply
          0
          • ODБOïO ODБOï

            @amarism

            color:"black"
            
            A Offline
            A Offline
            amarism
            wrote on last edited by amarism
            #5

            @LeLev Still not working . I am taking a grid and inside grid i will take 4 pushbutton . i will try to fix the backgroung color black.
            0_1539594715684_grid.png
            but still background color not updated

            0_1539594836203_grid.png

            ODБOïO 1 Reply Last reply
            0
            • A amarism

              @LeLev Still not working . I am taking a grid and inside grid i will take 4 pushbutton . i will try to fix the backgroung color black.
              0_1539594715684_grid.png
              but still background color not updated

              0_1539594836203_grid.png

              ODБOïO Offline
              ODБOïO Offline
              ODБOï
              wrote on last edited by
              #6

              @amarism

              import QtQuick 2.0
              import QtQuick.Window 2.0
              import QtQuick.Layouts 1.3
              import QtQuick.Controls 2.2
              
              Window {
                  visible: true
                  width: 800
                  height: 600
                  Rectangle{
                      id:backGround
                      color: "black"
                      height: 200
                      width: 400
                      GridLayout{
                          anchors.fill: parent
                          rows:2
                          columns:2
                          rowSpacing: 25
                          columnSpacing: 25
                          Repeater{
                              model : 4
                              Button {
                                  text: "btn " + index
                                  Layout.fillHeight: true
                                  Layout.fillWidth: true
                              }
                          }
                      }
                  }
              }
              
              
              A 1 Reply Last reply
              0
              • ODБOïO ODБOï

                @amarism

                import QtQuick 2.0
                import QtQuick.Window 2.0
                import QtQuick.Layouts 1.3
                import QtQuick.Controls 2.2
                
                Window {
                    visible: true
                    width: 800
                    height: 600
                    Rectangle{
                        id:backGround
                        color: "black"
                        height: 200
                        width: 400
                        GridLayout{
                            anchors.fill: parent
                            rows:2
                            columns:2
                            rowSpacing: 25
                            columnSpacing: 25
                            Repeater{
                                model : 4
                                Button {
                                    text: "btn " + index
                                    Layout.fillHeight: true
                                    Layout.fillWidth: true
                                }
                            }
                        }
                    }
                }
                
                
                A Offline
                A Offline
                amarism
                wrote on last edited by
                #7

                @LeLev How to Define Q_PROPERTY in mainwidow.h to use QML

                ODБOïO 1 Reply Last reply
                0
                • A amarism

                  @LeLev How to Define Q_PROPERTY in mainwidow.h to use QML

                  ODБOïO Offline
                  ODБOïO Offline
                  ODБOï
                  wrote on last edited by
                  #8

                  @amarism what is your project type ? QtQuick Application or Widget Application ? Or are you trying to combine both ?

                  A 1 Reply Last reply
                  0
                  • ODБOïO ODБOï

                    @amarism what is your project type ? QtQuick Application or Widget Application ? Or are you trying to combine both ?

                    A Offline
                    A Offline
                    amarism
                    wrote on last edited by
                    #9

                    @LeLev QTQuick Widget Application and initially i have this file(.h, .cpp, .main.cpp, .pro, .ui) and then i will add one .qml file.

                    1 Reply Last reply
                    0
                    • ODБOïO Offline
                      ODБOïO Offline
                      ODБOï
                      wrote on last edited by
                      #10

                      https://wiki.qt.io/How_to_Change_the_Background_Color_of_QWidget

                      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