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 create a qml component for currency?
Forum Updated to NodeBB v4.3 + New Features

How to create a qml component for currency?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 614 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.
  • N Offline
    N Offline
    NTMS
    wrote on last edited by
    #1

    Hi,

    I am new to qml and try to use Column and Row layout. But it seems I am having difficult to combine.
    I dont want to use canvas. So; how can I design below component?

    I can use columnlayouts for Buy and 0.0000 but I am having difficulty to combine like below picture.

    0_1520932558726_usd.jpg

    J.HilkJ 1 Reply Last reply
    0
    • N NTMS

      Hi,

      I am new to qml and try to use Column and Row layout. But it seems I am having difficult to combine.
      I dont want to use canvas. So; how can I design below component?

      I can use columnlayouts for Buy and 0.0000 but I am having difficulty to combine like below picture.

      0_1520932558726_usd.jpg

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

      @NTMS
      don't expect such a detailed example every time.

      import QtQuick 2.9
      
      Rectangle {
          id: root
          
          radius: width/10
          
          property alias topText: textAtTop.text
          
          Rectangle {
              id: topItem
              anchors.left: parent.left
              anchors.right: parent.right
              anchors.top: parent.top
              anchors.bottom: parent.verticalCenter
              
              color:"orange"
              
              Text{
                  id:textAtTop
                  color: "white"
                  horizontalAlignment: Qt.AlignHCenter
                  verticalAlignment: Qt.AlignVCenter
                  
                  text: qsTr("$")
              }
          }
          
          Item {
              id: bottemItem
              anchors.left:parent.left
              anchors.right: parent.right
              anchors.top: topItem.bottom
              anchors.bottom: parent.bottom
              
              Item{
                  id:bottemLeft
                  anchors.left: parent.left
                  anchors.top: parent.top
                  anchors.bottom: parent.bottom
                  width: (parent.width/2)-1
                  Text{
                      anchors.top: parent.top
                      anchors.left: parent.left
                      anchors.right: parent.right
                      anchors.bottom: parent.verticalCenter
                      
                      color:"orange"
                      text: "Buy"
                      
                      horizontalAlignment: Qt.AlignHCenter
                      verticalAlignment: Qt.AlignVCenter
                  }
                  
                  Text{
                      anchors.top: parent.verticalCenter
                      anchors.bottom: parent.bottom
                      anchors.left: parent.left
                      anchors.right: parent.right
                      
                      color:"black"
                      text: "0.0000"
                      
                      horizontalAlignment: Qt.AlignHCenter
                      verticalAlignment: Qt.AlignVCenter
                  }
              }
              
              Rectangle{
                  id:seperator
                  anchors.top: parent.top
                  anchors.bottom: parent.bottom
                  anchors.horizontalCenter: parent.horizontalCenter
                  anchors.topMargin: height/15
                  anchors.bottomMargin: height/15
                  
                  width: 2
                  
                  color:"black"
              }
              
              Item {
                  id: bottemRight
                  anchors.right: parent.right
                  anchors.top: parent.top
                  anchors.bottom: parent.bottom
                  width: (parent.width/2)-1
                  
                  Text{
                      anchors.top: parent.top
                      anchors.left: parent.left
                      anchors.right: parent.right
                      anchors.bottom: parent.verticalCenter
                      
                      color:"orange"
                      text: "Sell"
                      
                      horizontalAlignment: Qt.AlignHCenter
                      verticalAlignment: Qt.AlignVCenter
                  }
                  
                  Text{
                      anchors.top: parent.verticalCenter
                      anchors.bottom: parent.bottom
                      anchors.left: parent.left
                      anchors.right: parent.right
                      
                      color:"black"
                      text: "0.0000"
                      
                      horizontalAlignment: Qt.AlignHCenter
                      verticalAlignment: Qt.AlignVCenter
                  }
              }
          }
      }
      
      

      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
      • N Offline
        N Offline
        NTMS
        wrote on last edited by
        #3

        @J-Hilk thank you. It is more than enough for me to study with your code. Kind Regards

        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