Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Unsolved How to set the background color for gridLaout?

    QML and Qt Quick
    2
    10
    2530
    Loading More Posts
    • 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
      amarism last edited by

      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ï 1 Reply Last reply Reply Quote 0
      • ODБOï
        ODБOï @amarism last edited by

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

        A 1 Reply Last reply Reply Quote 0
        • A
          amarism @ODБOï last edited by

          @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ï 1 Reply Last reply Reply Quote 0
          • ODБOï
            ODБOï @amarism last edited by

            @amarism

            color:"black"
            
            A 1 Reply Last reply Reply Quote 0
            • A
              amarism @ODБOï last edited by 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ï 1 Reply Last reply Reply Quote 0
              • ODБOï
                ODБOï @amarism last edited by

                @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 Reply Quote 0
                • A
                  amarism @ODБOï last edited by

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

                  ODБOï 1 Reply Last reply Reply Quote 0
                  • ODБOï
                    ODБOï @amarism last edited by

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

                    A 1 Reply Last reply Reply Quote 0
                    • A
                      amarism @ODБOï last edited by

                      @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 Reply Quote 0
                      • ODБOï
                        ODБOï last edited by

                        https://wiki.qt.io/How_to_Change_the_Background_Color_of_QWidget

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post