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. Qtcreator ui design and runtime display not same
Forum Updated to NodeBB v4.3 + New Features

Qtcreator ui design and runtime display not same

Scheduled Pinned Locked Moved Solved QML and Qt Quick
8 Posts 2 Posters 967 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.
  • R Offline
    R Offline
    RyuShai
    wrote on last edited by
    #1

    i cant found problem here
    i put 3 button on RowLlayout and expect it look like below (is in qtcreator design mode preview)
    1_1552287646978_Screenshot from 2019-03-11 14-00-34.png
    but runtime it look like this
    0_1552287646977_Screenshot from 2019-03-11 13-59-44.png

    here the code i using:

     Rectangle {
            id: toolbar
            height: 40
            color: "red" //"#cdf8ac"
            anchors.right: parent.right
            anchors.rightMargin: 0
            anchors.left: parent.left
            anchors.leftMargin: 0
            anchors.top: topAccent.bottom
            RowLayout {
                anchors.topMargin: 0
                spacing: 0
                anchors.fill: parent
                height: 40
                ComboBox {
                    id: displayType
                    model: ["NvUniq", "Unknow", "NV"]
                    Layout.fillHeight: true
                    Layout.alignment: Qt.AlignHCenter
                    height: 40
                    }
                }
                Button {
                    id: fromDate
                    property date day: new Date()
                    text: "from"
                }
                Button {
                    id: toDate
                    property date day: new Date()
                    text: "to"
                }
            }
        }
    
    1 Reply Last reply
    0
    • Shrinidhi UpadhyayaS Offline
      Shrinidhi UpadhyayaS Offline
      Shrinidhi Upadhyaya
      wrote on last edited by
      #2

      Hi @RyuShai , i dont know how you are even getting the way you have displayed it in the runtime look as you are closing the RowLayout after the Combox box only, and then creating the other Buttons which will be by default aligned on the topLeft of the rectangle(id:toolbar or red color rectangle).

      Have made few changes to meet your expected output please have a look:-

         Rectangle {
          id: toolbar
      
          anchors.right: parent.right
          anchors.left: parent.left
          anchors.top: topAccent.bottom
          height: 40
          color: "red" //"#cdf8ac"
      
          RowLayout {
              anchors.left: parent.left
              anchors.right: parent.right
              anchors.leftMargin: 40
              anchors.rightMargin: 40
              height: parent.height
              spacing: 40
      
              ComboBox {
                  id: displayType
                  model: ["NvUniq", "Unknow", "NV"]
                  Layout.fillHeight: true
                  Layout.fillWidth: true
              }
      
              Button {
                  id: fromDate
                  property date day: new Date()
                  text: "from"
                  Layout.fillHeight: true
                  Layout.fillWidth: true
              }
      
              Button {
                  id: toDate
                  property date day: new Date()
                  text: "to"
                  Layout.fillHeight: true
                  Layout.fillWidth: true
              }
          }
      }
      

      Shrinidhi Upadhyaya.
      Upvote the answer(s) that helped you to solve the issue.

      R 1 Reply Last reply
      2
      • Shrinidhi UpadhyayaS Shrinidhi Upadhyaya

        Hi @RyuShai , i dont know how you are even getting the way you have displayed it in the runtime look as you are closing the RowLayout after the Combox box only, and then creating the other Buttons which will be by default aligned on the topLeft of the rectangle(id:toolbar or red color rectangle).

        Have made few changes to meet your expected output please have a look:-

           Rectangle {
            id: toolbar
        
            anchors.right: parent.right
            anchors.left: parent.left
            anchors.top: topAccent.bottom
            height: 40
            color: "red" //"#cdf8ac"
        
            RowLayout {
                anchors.left: parent.left
                anchors.right: parent.right
                anchors.leftMargin: 40
                anchors.rightMargin: 40
                height: parent.height
                spacing: 40
        
                ComboBox {
                    id: displayType
                    model: ["NvUniq", "Unknow", "NV"]
                    Layout.fillHeight: true
                    Layout.fillWidth: true
                }
        
                Button {
                    id: fromDate
                    property date day: new Date()
                    text: "from"
                    Layout.fillHeight: true
                    Layout.fillWidth: true
                }
        
                Button {
                    id: toDate
                    property date day: new Date()
                    text: "to"
                    Layout.fillHeight: true
                    Layout.fillWidth: true
                }
            }
        }
        
        R Offline
        R Offline
        RyuShai
        wrote on last edited by
        #3

        @Shrinidhi-Upadhyaya said in Qtcreator ui design and runtime display not same:

        anchors.left: parent.left
        anchors.right: parent.right
        anchors.leftMargin: 40
        anchors.rightMargin: 40
        height: parent.height

        still not working, i throught some bug on qtcreator or personal machine. to night i will test on other machine

        1 Reply Last reply
        0
        • Shrinidhi UpadhyayaS Offline
          Shrinidhi UpadhyayaS Offline
          Shrinidhi Upadhyaya
          wrote on last edited by
          #4

          Hi @RyuShai , can you copy paste my complete code and run it, and if possible can you attach the screenshot of the output.

          Shrinidhi Upadhyaya.
          Upvote the answer(s) that helped you to solve the issue.

          R 1 Reply Last reply
          0
          • Shrinidhi UpadhyayaS Shrinidhi Upadhyaya

            Hi @RyuShai , can you copy paste my complete code and run it, and if possible can you attach the screenshot of the output.

            R Offline
            R Offline
            RyuShai
            wrote on last edited by RyuShai
            #5

            @Shrinidhi-Upadhyaya
            my mistake, complete code is worked, likke i expected

            any idea why my code failed ?

            edit again: i set from and to button filllheight and problem solved

            1 Reply Last reply
            0
            • Shrinidhi UpadhyayaS Offline
              Shrinidhi UpadhyayaS Offline
              Shrinidhi Upadhyaya
              wrote on last edited by
              #6

              Hi @RyuShai , please have a look at my comments below:-

                  Rectangle {
                  id: toolbar
              
                  //####Not Needed as by default the value of margins is 0
                  //        anchors.rightMargin: 0
                  //        anchors.leftMargin: 0
                  anchors.right: parent.right
                  anchors.left: parent.left
                  anchors.top: topAccent.bottom
                  height: 40
                  color: "red" //"#cdf8ac"
              
                  RowLayout {
                      anchors.left: parent.left
                      anchors.right: parent.right
                      anchors.leftMargin: 40
                      anchors.rightMargin: 40
                      height: parent.height
                      spacing: 40
              
                      ComboBox {
                          id: displayType
                          model: ["NvUniq", "Unknow", "NV"]
                          Layout.fillHeight: true
                          Layout.fillWidth: true
              
                          //####Will not work because you need to use Layout.preferredHeight: 40
                          //                height: 40
              
                      }
                      //####You are closing the RowLayout here which is the biggest problem,thats why you are not getting the UI properly
               //        }
              
                      Button {
                          id: fromDate
                          property date day: new Date()
                          text: "from"
                          //####Every component needs a height and width,so you need to set that
                          Layout.fillHeight: true
                          Layout.fillWidth: true
                      }
              
                      Button {
                          id: toDate
                          property date day: new Date()
                          text: "to"
                          //####Every component needs a height and width,so you need to set that
                          Layout.fillHeight: true
                          Layout.fillWidth: true
                      }
                  }
              }
              

              Shrinidhi Upadhyaya.
              Upvote the answer(s) that helped you to solve the issue.

              1 Reply Last reply
              2
              • R Offline
                R Offline
                RyuShai
                wrote on last edited by
                #7

                hi !@Shrinidhi-Upadhyaya
                i dont want create topic so could i ask you thing ?

                i have

                Struct T{
                int i;
                }
                T t;
                t.i =1;
                QList<T> list;
                list.push_back(t);
                

                how can i change t.i in list from 1 to 2 ?

                1 Reply Last reply
                0
                • Shrinidhi UpadhyayaS Offline
                  Shrinidhi UpadhyayaS Offline
                  Shrinidhi Upadhyaya
                  wrote on last edited by
                  #8

                  Hi @RyuShai , there is a replace function available, you can have a look into QList Documentation.
                  And for further doubts etc you can follow me and ping me anytime.

                  Shrinidhi Upadhyaya.
                  Upvote the answer(s) that helped you to solve the issue.

                  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