UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login
    1. Home
    2. ifelse
    I
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Groups 0

    ifelse

    @ifelse

    0
    Reputation
    4
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    ifelse Unfollow Follow

    Latest posts made by ifelse

    • RE: beginner question: qml if else with a switch

      @ikoz

      could you be so kind an give me a example

      beacuse how to define a variable in qml code:

      • add the icon

      here is the default Main.qml
      when create a new project.

      import QtQuick 2.7
      import QtQuick.Controls 2.2
      import Lomiri.Components 1.3
      import QtQuick.Layouts 1.3
      import Qt.labs.settings 1.0
      
      import Greeter 1.0
      
      ApplicationWindow {
          id: root
          objectName: 'mainView'
      
          width: units.gu(45)
          height: units.gu(75)
          visible: true
      
          Greeter {
              id: greeter
              name: "Rust + Ubuntu Touch"
          }
      
          Page {
              anchors.fill: parent
      
              header: PageHeader {
                  id: header
                  title: i18n.tr('bla')
              }
      
                  Icon {
                      width: units.gu(5)
                      height: units.gu(5)
                      name: 'cancel'
                      
                  }
      
              ColumnLayout {
                  spacing: units.gu(2)
                  anchors {
                      margins: units.gu(2)
                      top: header.bottom
                      left: parent.left
                      right: parent.right
                      bottom: parent.bottom
                  }
      
                  Item {
                      Layout.fillHeight: true
                  }
      
                  Label {
                      id: label
                      text: i18n.tr('Press the button below!')
                  }
      
                  Button {
                      text: i18n.tr('Compute greeting')
                      onClicked: {
                          label.text = greeter.compute_greetings("Hello, ");
                      }
                  }
      
                  Switch {
                      checked: off
                      onClicked: {
                              label.text = greeter.compute_greetings("sw on");
                      }
      
                  }
      
      
                  Item {
                      Layout.fillHeight: true
                  }
              }
          }
      }
      
      posted in App Development
      I
      ifelse
    • beginner question: qml if else with a switch

      Hi,
      I wanna do the following - but have absolute no idea how!

      App with a switch.

      Icon {
                     if Switch.on (
                         width: units.gu(5)
                         height: units.gu(5)
                         name: 'flash-on'       
                     )
                    else if (
                         width: units.gu(5)
                         height: units.gu(5)
                         name: 'flash-off'
                      )
                    else (
                         width: units.gu(5)
                         height: units.gu(5)
                         name: 'cancel'
                    )  
                 }
      

      https://docs.ubports.com/projects/icons/en/latest/

      posted in App Development
      I
      ifelse