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. Customization of many elements
Forum Updated to NodeBB v4.3 + New Features

Customization of many elements

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
10 Posts 5 Posters 1.7k 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.
  • E Offline
    E Offline
    echo55
    wrote on last edited by
    #1

    Hi everybody,

    I'm currently doing a client for an app on Linux .

    I did most of the views but now i have some trouble with customization about many parts , maybe there is a book / website
    talking about customization more in depth because the books i saw didn't went really far.
    For example :

    • i want to do a textInput looking like that https://ibin.co/3yg8dqpQ0liD.png but i have that https://ibin.co/3yg8oSz4HiUc.png.
      and this for many others .

    Thank you .

    T 1 Reply Last reply
    0
    • E echo55

      Hi everybody,

      I'm currently doing a client for an app on Linux .

      I did most of the views but now i have some trouble with customization about many parts , maybe there is a book / website
      talking about customization more in depth because the books i saw didn't went really far.
      For example :

      • i want to do a textInput looking like that https://ibin.co/3yg8dqpQ0liD.png but i have that https://ibin.co/3yg8oSz4HiUc.png.
        and this for many others .

      Thank you .

      T Offline
      T Offline
      Tirupathi Korla
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      -1
      • Gojir4G Offline
        Gojir4G Offline
        Gojir4
        wrote on last edited by
        #3

        Hello, If you are using Qt Quick Controls 2, you can customize background and contentItem for every components which inherit from Control.

        Here is an example for your button:

        Button {
                id: button
                anchors.centerIn: parent
                text: "A Special Button"
                 
                background: Rectangle {
                    implicitWidth: 160
                    implicitHeight: 40
                    color: button.down ? "#80FFFFFF" : "#40FFFFFF"  
                    border.color: "white"        
                    border.width: 2
                    radius: 8            
                }
                
                 contentItem: Text {
                    text: button.text
                    font: button.font
                    
                    opacity: enabled ? 1.0 : 0.3
                    color: "white"
                    horizontalAlignment: Text.AlignLeft
                    verticalAlignment: Text.AlignVCenter
                    elide: Text.ElideRight
                }
            }
        
        E 1 Reply Last reply
        0
        • Gojir4G Gojir4

          Hello, If you are using Qt Quick Controls 2, you can customize background and contentItem for every components which inherit from Control.

          Here is an example for your button:

          Button {
                  id: button
                  anchors.centerIn: parent
                  text: "A Special Button"
                   
                  background: Rectangle {
                      implicitWidth: 160
                      implicitHeight: 40
                      color: button.down ? "#80FFFFFF" : "#40FFFFFF"  
                      border.color: "white"        
                      border.width: 2
                      radius: 8            
                  }
                  
                   contentItem: Text {
                      text: button.text
                      font: button.font
                      
                      opacity: enabled ? 1.0 : 0.3
                      color: "white"
                      horizontalAlignment: Text.AlignLeft
                      verticalAlignment: Text.AlignVCenter
                      elide: Text.ElideRight
                  }
              }
          
          E Offline
          E Offline
          echo55
          wrote on last edited by
          #4

          @Gojir4
          Great , it's what i wanted . Thank you.
          Is it possible to do that with text ? just text ? like if i want to do a clickable text ?

          1 Reply Last reply
          0
          • Gojir4G Offline
            Gojir4G Offline
            Gojir4
            wrote on last edited by
            #5

            for this you need to use a MouseArea:

            Text{
                text: "Hello"
                MouseArea{
                    anchors.fill: parent
                    onClicked: console.log("clicked !")
                }
            }
            
            J.HilkJ 1 Reply Last reply
            1
            • Gojir4G Gojir4

              for this you need to use a MouseArea:

              Text{
                  text: "Hello"
                  MouseArea{
                      anchors.fill: parent
                      onClicked: console.log("clicked !")
                  }
              }
              
              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              To add to @Gojir4 's example

              you can use the MouseArea to, for example, make visual changes. That indicate, that the user presses on the text item:

               Text{
                   text: "Hello"
                   color: mArea.pressed ? "blue" : "black" // Blue Text color when pressed, black color otherwise
                   MouseArea{
                       id:mArea
                       anchors.fill: parent
                       onClicked: console.log("clicked !")
                   }
               }
              

              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
              1
              • E Offline
                E Offline
                echo55
                wrote on last edited by
                #7

                Oh ok , it's a listener . i see , thanks

                1 Reply Last reply
                0
                • E Offline
                  E Offline
                  echo55
                  wrote on last edited by
                  #8

                  Hi , thank you again for all your answers.
                  I have a new one if you guys have some times.

                  I want to change the content of a view when i click on a button , kinda having a view inside a view no ?
                  I wanted to do that but i thought maybe there is another way, a better way than doing stackview inside stackview , right ?

                  Thanks.

                  1 Reply Last reply
                  0
                  • E Offline
                    E Offline
                    echo55
                    wrote on last edited by
                    #9

                    Someone knows ? maybe i should start a new thread.

                    ODБOïO 1 Reply Last reply
                    0
                    • E echo55

                      Someone knows ? maybe i should start a new thread.

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

                      @echo55 hi,

                      @echo55 said in Customization of many elements:

                      I want to change the content of a view when i click on a button , kinda having a view inside a view no ?

                      Take a look at Loader QML type : http://doc.qt.io/qt-5/qml-qtquick-loader.html
                      You can change 'source' property when click on button for exemple

                      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